eaf-base-api 1.3__tar.gz → 1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eaf_base_api
3
- Version: 1.3
3
+ Version: 1.6
4
4
  Summary: A base API for EchterAlsFake's Porn APIs
5
5
  Home-page: https://github.com/EchterAlsFake/eaf_base_api
6
6
  Author: Johannes Habel
@@ -2,6 +2,7 @@ import requests
2
2
  import logging
3
3
  import time
4
4
  import string
5
+ import os
5
6
 
6
7
  from base_api.modules.quality import Quality
7
8
  from base_api.modules.progress_bars import Callback
@@ -24,11 +25,11 @@ base_qualities = ["250p", "360p", "480p", "720p", "1080p", "1440p", "2160p"]
24
25
 
25
26
  class Core:
26
27
  @classmethod
27
- def get_content(cls, url, headers=None, cookies=None):
28
+ def get_content(cls, url, headers=None, cookies=None, stream=False):
28
29
  for i in range(MAX_RETRIES):
29
30
  try:
30
31
  logging.debug(f"Trying to fetch {url} / Attempt: [{i+1}]")
31
- response = requests.get(url, headers=headers, cookies=cookies)
32
+ response = requests.get(url, headers=headers, cookies=cookies, stream=stream)
32
33
  if response.status_code == 200:
33
34
  logging.info(f"Successfully fetched {url} on attempt [{i+1}]")
34
35
  return response.content
@@ -151,4 +152,18 @@ class Core:
151
152
  """
152
153
  illegal_chars = '<>:"/\\|?*'
153
154
  cleaned_title = ''.join([char for char in title if char in string.printable and char not in illegal_chars])
154
- return cleaned_title
155
+ return cleaned_title
156
+
157
+ @classmethod
158
+ def return_path(cls, video, args):
159
+ path = args.output
160
+ if args.use_title:
161
+ if not str(path).endswith(os.sep):
162
+ path += os.sep
163
+
164
+ path += video.title + ".mp4"
165
+
166
+ else:
167
+ path = args.output
168
+
169
+ return path
@@ -0,0 +1,2 @@
1
+ MAX_RETRIES = 4
2
+ FFMPEG_PATH = "ffmpeg"
@@ -7,6 +7,13 @@ import os
7
7
  from ffmpeg_progress_yield import FfmpegProgress
8
8
  from concurrent.futures import ThreadPoolExecutor, as_completed
9
9
  from typing import Callable, List
10
+ from base_api.modules.progress_bars import Callback
11
+
12
+ try:
13
+ from base_api.modules.consts import FFMPEG_PATH
14
+
15
+ except (ModuleNotFoundError, ImportError):
16
+ from .consts import FFMPEG_PATH
10
17
 
11
18
  CallbackType = Callable[[int, int], None]
12
19
 
@@ -109,7 +116,7 @@ def FFMPEG(video, quality, callback, path, start=0) -> bool:
109
116
 
110
117
  # Build the command for FFMPEG as a list directly
111
118
  command = [
112
- "ffmpeg",
119
+ FFMPEG_PATH,
113
120
  "-i", new_url, # Input URL
114
121
  "-bsf:a", "aac_adtstoasc",
115
122
  "-y", # Overwrite output files without asking
@@ -126,4 +133,34 @@ def FFMPEG(video, quality, callback, path, start=0) -> bool:
126
133
  if progress == 100:
127
134
  return True
128
135
 
129
- return False
136
+ return False
137
+
138
+
139
+ def legacy_download(stream, path, url, callback=None):
140
+ response = requests.get(url, stream=stream)
141
+ file_size = int(response.headers.get('content-length', 0))
142
+
143
+ if callback is None:
144
+ progress_bar = Callback()
145
+
146
+ downloaded_so_far = 0
147
+
148
+ if not os.path.exists(path):
149
+ with open(path, 'wb') as file:
150
+ for chunk in response.iter_content(chunk_size=1024):
151
+ file.write(chunk)
152
+ downloaded_so_far += len(chunk)
153
+
154
+ if callback:
155
+ callback(downloaded_so_far, file_size)
156
+
157
+ else:
158
+ progress_bar.text_progress_bar(downloaded=downloaded_so_far, total=file_size)
159
+
160
+ if not callback:
161
+ del progress_bar
162
+
163
+ return True
164
+
165
+ else:
166
+ raise FileExistsError("The file already exists.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eaf_base_api
3
- Version: 1.3
3
+ Version: 1.6
4
4
  Summary: A base API for EchterAlsFake's Porn APIs
5
5
  Home-page: https://github.com/EchterAlsFake/eaf_base_api
6
6
  Author: Johannes Habel
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="eaf_base_api",
5
- version="1.3",
5
+ version="1.6",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "requests", "ffmpeg-progress-yield"
@@ -1 +0,0 @@
1
- MAX_RETRIES = 4
File without changes
File without changes