diff --git a/.gitignore b/.gitignore index f9d6f36..9f08978 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,9 @@ bin lib lib64 *__pycache__ -pyvenv.cfg \ No newline at end of file +pyvenv.cfg + +# Project specific +videos/ +tmp/ +Src/Util/file_list.txt \ No newline at end of file diff --git a/Src/Api/tv.py b/Src/Api/tv.py index 4ab1c7c..008f693 100644 --- a/Src/Api/tv.py +++ b/Src/Api/tv.py @@ -8,6 +8,7 @@ from Src.Util.m3u8 import dw_m3u8 # General import import requests, os, re, json, sys +from enum import Enum from bs4 import BeautifulSoup # [func] @@ -23,7 +24,7 @@ def get_info_tv(id_film, title_name, site_version, domain): 'User-Agent': get_headers() }) - if req.ok(): + if req.ok: return req.json()['props']['title']['seasons_count'] else: console.log(f"[red]Error: {req.status_code}") @@ -116,7 +117,11 @@ def actually_dw(tv_id, eps, index_ep_select, domain, token, tv_name, season_sele -def main_dw_tv(tv_id, tv_name, version, domain): +class TvDownloadBehaviour(Enum): + DOWNLOAD_EPISODE = 0 + DOWNLOAD_SEASON = 1 + +def main_dw_tv(tv_id, tv_name, version, domain, tv_download_behaviour): token = get_token(tv_id, domain) @@ -125,16 +130,18 @@ def main_dw_tv(tv_id, tv_name, version, domain): console.print(f"[blue]Season find: [red]{get_info_tv(tv_id, tv_name, version, domain)}") season_select = msg.ask("\n[green]Insert season number: ") - eps = get_info_season(tv_id, tv_name, domain, version, token, season_select) - for ep in eps: - console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}") - index_ep_select = msg.ask("\n[green]Insert ep number (use * for all episodes): ") - if(index_ep_select == '*'): + console.print(tv_download_behaviour) + + eps = get_info_season(tv_id, tv_name, domain, version, token, season_select) + + if (tv_download_behaviour == TvDownloadBehaviour.DOWNLOAD_SEASON.value): for ep in eps: + console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}") index_ep_select = int(ep['n']) - 1 actually_dw(tv_id, eps, index_ep_select, domain, token, tv_name, season_select, lower_tv_name) - return - - index_ep_select = int(index_ep_select) - 1 - actually_dw(tv_id, eps, index_ep_select, domain, token, tv_name, season_select, lower_tv_name) \ No newline at end of file + else: + for ep in eps: + console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}") + index_ep_select = int(msg.ask("\n[green]Insert ep number: ")) - 1 + actually_dw(tv_id, eps, index_ep_select, domain, token, tv_name, season_select, lower_tv_name) \ No newline at end of file diff --git a/run.py b/run.py index d2fbf56..e3a0986 100644 --- a/run.py +++ b/run.py @@ -34,7 +34,8 @@ def main(): else: console.print(f"[green]\nTv select: {db_title[index_select]['name']}") - download_tv(db_title[index_select]['id'], db_title[index_select]['name'].replace(" ", "+"), site_version, domain) + tv_download_behaviour = int(msg.ask(f"\n[blue]Do you want to download specific episodes or an entire season? (0-> Specific | 1 -> Entire season): ", choices=['0', '1'])) + download_tv(db_title[index_select]['id'], db_title[index_select]['name'].replace(" ", "+"), site_version, domain, tv_download_behaviour) console.print("\n[red]Done")