|
1 | 1 | import os |
2 | 2 | import logging |
3 | | -import traceback |
4 | | - |
| 3 | +import threading |
5 | 4 | import time |
6 | 5 | import hmac |
7 | 6 | import hashlib |
| 7 | + |
8 | 8 | from base_api import BaseCore |
9 | 9 | from bs4 import BeautifulSoup |
10 | 10 | from urllib.parse import quote |
11 | 11 | from functools import cached_property |
12 | 12 | from typing import Optional, Generator, List |
13 | 13 | from base_api.base import setup_logger, Helper |
14 | 14 | from base_api.modules.config import RuntimeConfig |
15 | | -from base_api.modules.progress_bars import Callback |
16 | 15 | from concurrent.futures import ThreadPoolExecutor, as_completed |
17 | 16 |
|
18 | 17 | BASE_HOST = "client-rapi-missav.recombee.com" |
@@ -121,7 +120,7 @@ def genres(self) -> List[str]: |
121 | 120 | for a_tag in a_tags: |
122 | 121 | genres.append(a_tag.text.strip()) |
123 | 122 |
|
124 | | - return a_tags |
| 123 | + return genres |
125 | 124 |
|
126 | 125 | except IndexError: |
127 | 126 | return [] |
@@ -173,22 +172,34 @@ def get_segments(self, quality: str) -> list: |
173 | 172 | """Returns the list of HLS segments for a given quality""" |
174 | 173 | return self.core.get_segments(quality=quality, m3u8_url_master=self.m3u8_base_url) |
175 | 174 |
|
176 | | - def download(self, quality: str, downloader: str, path: str = "./", no_title=False, |
177 | | - callback=Callback.text_progress_bar, |
178 | | - remux: bool = False, remux_callback = None) -> bool: |
179 | | - """Downloads the video from HLS""" |
180 | | - if no_title is False: |
181 | | - path = os.path.join(path, self.core.truncate(self.core.strip_title(self.title)) + ".mp4") |
| 175 | + def download(self, quality, path="./", callback=None, no_title=False, remux: bool = False, |
| 176 | + callback_remux=None, start_segment: int = 0, stop_event: Optional[threading.Event] = None, |
| 177 | + segment_state_path: Optional[str] = None, segment_dir: Optional[str] = None, |
| 178 | + return_report: bool = False, cleanup_on_stop: bool = True, keep_segment_dir: bool = False |
| 179 | + ) -> bool: |
| 180 | + """ |
| 181 | + :param callback: |
| 182 | + :param quality: |
| 183 | + :param path: |
| 184 | + :param no_title: |
| 185 | + :param remux: |
| 186 | + :param callback_remux: |
| 187 | + :param start_segment: |
| 188 | + :param stop_event: |
| 189 | + :param segment_state_path: |
| 190 | + :param segment_dir: |
| 191 | + :param return_report: |
| 192 | + :param cleanup_on_stop: |
| 193 | + :param keep_segment_dir: |
| 194 | + :return: |
| 195 | + """ |
| 196 | + if not no_title: |
| 197 | + path = os.path.join(path, f"{self.title}.mp4") |
182 | 198 |
|
183 | | - try: |
184 | | - self.core.download(video=self, quality=quality, path=path, callback=callback, downloader=downloader, |
185 | | - remux=remux, callback_remux=remux_callback) |
186 | | - return True |
187 | | - |
188 | | - except Exception: |
189 | | - error = traceback.format_exc() |
190 | | - self.logger.error(error) |
191 | | - return False |
| 199 | + return self.core.download(video=self, quality=quality, path=path, callback=callback, remux=remux, |
| 200 | + callback_remux=callback_remux, start_segment=start_segment, stop_event=stop_event, |
| 201 | + segment_state_path=segment_state_path, segment_dir=segment_dir, return_report=return_report, |
| 202 | + cleanup_on_stop=cleanup_on_stop, keep_segment_dir=keep_segment_dir) |
192 | 203 |
|
193 | 204 |
|
194 | 205 | class Client(Helper): |
|
0 commit comments