Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/feedcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def get_domain(link):
def fetcher(category, latest=False, show_progress=False, workers=27):
data = read_data(category)
feeddata = cache(latest)
colour = "%06x" % random.randint(0, 0xFFFFFF)

with ThreadPoolExecutor(max_workers=workers) as executor:
results = list(
tqdm(
Expand All @@ -46,11 +48,13 @@ def fetcher(category, latest=False, show_progress=False, workers=27):
total=len(data),
disable=show_progress,
leave=False,
colour="#" + str(colour),
)
)

return results


def filter_mpeg_link(result):
for item in result:
# filter only mp3 links
Expand All @@ -60,6 +64,7 @@ def filter_mpeg_link(result):

return result


def podcasts_feeds(show_progress=False, workers=27):
result = fetcher("podcasts", True, show_progress, workers)

Expand Down
6 changes: 4 additions & 2 deletions defe/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def main():
if args.feed == "feeders":
feeds = ["general", "news", "podcasts", "newsletters"]
print(
Style.BRIGHT + "\ndefe fetches feeds of these sources 😃", end="\n\n",
Style.BRIGHT + "\ndefe fetches feeds of these sources 😃",
end="\n\n",
)
for f in feeds:
print("\n" + Fore.BLUE + Style.BRIGHT + f.capitalize(), end=" ")
Expand All @@ -144,7 +145,8 @@ def main():

print("\n\n" + Style.BRIGHT + "Want to add more ? 🤔")
print(
Style.BRIGHT + "Open a PR at https://github.com/Bhupesh-V/defe", end="\n\n",
Style.BRIGHT + "Open a PR at https://github.com/Bhupesh-V/defe",
end="\n\n",
)


Expand Down
4 changes: 2 additions & 2 deletions defe/defe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class NoSuchFeederCategory(Exception):
class feed:
def __init__(self, progress=True):
"""Args
- progress
- workers
- progress
- workers
"""
self.show_progress = progress
self.feeder_categories = ["general", "news", "podcasts", "newsletters"]
Expand Down
52 changes: 34 additions & 18 deletions defe/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from colorama import Fore, Style, init
import webbrowser
import sys
import vlc##
import vlc ##


def defy(src, title, link):
Expand All @@ -29,23 +29,39 @@ def defy_prompt(feed, podcasts=False):
)
print(Style.RESET_ALL)
if podcasts:
player = vlc.MediaPlayer(feed[int(feed_to_open) -1]["links"][0]["href"])
print(Fore.GREEN + Style.BRIGHT + "Now playing: " + Fore.YELLOW + Style.BRIGHT + feed[int(feed_to_open)-1]["title"])
player.play()
while 1:
action = str(input(Fore.GREEN + Style.BRIGHT + "pause/stop [p/s] : ")).lower()
if action == "p":
player.pause()
input(Fore.GREEN + Style.BRIGHT + "Press enter to continue : ")
player.play()
elif action == "s":
player.stop()
break
else:
print(Style.BRIGHT + "Please type 'p' to pause or 's' to stop the podcast")
else:
print(Style.BRIGHT + "Opening Link in your default browser ...")
webbrowser.open(feed[int(feed_to_open) - 1].link)
player = vlc.MediaPlayer(
feed[int(feed_to_open) - 1]["links"][0]["href"]
)
print(
Fore.GREEN
+ Style.BRIGHT
+ "Now playing: "
+ Fore.YELLOW
+ Style.BRIGHT
+ feed[int(feed_to_open) - 1]["title"]
)
player.play()
while 1:
action = str(
input(Fore.GREEN + Style.BRIGHT + "pause/stop [p/s] : ")
).lower()
if action == "p":
player.pause()
input(
Fore.GREEN + Style.BRIGHT + "Press enter to continue : "
)
player.play()
elif action == "s":
player.stop()
break
else:
print(
Style.BRIGHT
+ "Please type 'p' to pause or 's' to stop the podcast"
)
else:
print(Style.BRIGHT + "Opening Link in your default browser ...")
webbrowser.open(feed[int(feed_to_open) - 1].link)
except ValueError:
print(Style.BRIGHT + "Enter Valid Index 😟")
except KeyboardInterrupt:
Expand Down