Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Removed live episodes from the downloadable episodes (fixes #26), min…
Browse files Browse the repository at this point in the history
…or optimizations
  • Loading branch information
CoffeeStraw committed Apr 1, 2021
1 parent 0ed494a commit 00ccf09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def dl_from_vvvvid(url, requests_obj):
)
)

# Check for empty seasons
if not seasons:
print(
f'\n{Fore.YELLOW}[WARNING]{Style.RESET_ALL} L\'URL fornito ("{url}") non contiene alcun episodio scaricabile.\nSi prega di controllarlo e riprovare.\n'
)

# Iterate over the seasons obtained from the url in the txt
for season_id, season in seasons.items():
# Creating content directory if not existing
Expand Down Expand Up @@ -158,7 +164,7 @@ def main():
Fore.YELLOW
+ "NOTA BENE: "
+ Style.RESET_ALL
+ "siccome lo script è stato lanciato da Windows i nomi delle cartelle e dei file potrebbero subire delle variazioni.\n"
+ "siccome lo script è stato lanciato da Windows i nomi delle cartelle e dei file creati potrebbero subire delle variazioni.\n"
)

# Creating persistent session
Expand Down
17 changes: 13 additions & 4 deletions src/vvvvid.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,23 @@ def get_seasons(requests_obj, url, show_id):

if additional_infos:
season_id, episode_id = additional_infos.groups()

seasons = {season_id: seasons[season_id]}
episodes = deepcopy(seasons[season_id]["episodes"])

for e in episodes:
if str(e["video_id"]) != episode_id:
for _ in range(len(seasons[season_id]["episodes"])):
curr_ep = seasons[season_id]["episodes"][0]
if str(curr_ep["video_id"]) != episode_id:
del seasons[season_id]["episodes"][0]
else:
break

# Check for invalid episodes and delete them (atm of writing, only "lives" are considered invalid)
for season_id in list(seasons.keys()):
for i in range(len(seasons[season_id]["episodes"]) - 1, -1, -1):
if "live" in seasons[season_id]["episodes"][i]:
del seasons[season_id]["episodes"][i]

# Check if current season has any episode left
if not len(seasons[season_id]["episodes"]):
del seasons[season_id]

return seasons

0 comments on commit 00ccf09

Please sign in to comment.