media-downloader 0.11.3__py2.py3-none-any.whl → 0.11.5__py2.py3-none-any.whl
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.
Potentially problematic release.
This version of media-downloader might be problematic. Click here for more details.
- media_downloader/__init__.py +2 -0
- media_downloader/media_downloader.py +87 -68
- media_downloader/version.py +3 -3
- {media_downloader-0.11.3.dist-info → media_downloader-0.11.5.dist-info}/LICENSE +1 -1
- {media_downloader-0.11.3.dist-info → media_downloader-0.11.5.dist-info}/METADATA +3 -3
- media_downloader-0.11.5.dist-info/RECORD +9 -0
- media_downloader-0.11.3.dist-info/RECORD +0 -9
- {media_downloader-0.11.3.dist-info → media_downloader-0.11.5.dist-info}/WHEEL +0 -0
- {media_downloader-0.11.3.dist-info → media_downloader-0.11.5.dist-info}/entry_points.txt +0 -0
- {media_downloader-0.11.3.dist-info → media_downloader-0.11.5.dist-info}/top_level.txt +0 -0
media_downloader/__init__.py
CHANGED
|
@@ -5,6 +5,8 @@ import os
|
|
|
5
5
|
import sys
|
|
6
6
|
import re
|
|
7
7
|
import getopt
|
|
8
|
+
from typing import List
|
|
9
|
+
|
|
8
10
|
import requests
|
|
9
11
|
import yt_dlp
|
|
10
12
|
from multiprocessing import Pool
|
|
@@ -13,13 +15,13 @@ from media_downloader.version import __version__, __author__, __credits__
|
|
|
13
15
|
|
|
14
16
|
class StdOutLogger(object):
|
|
15
17
|
def debug(self, msg):
|
|
16
|
-
print(f
|
|
18
|
+
print(f"{msg}")
|
|
17
19
|
|
|
18
20
|
def warning(self, msg):
|
|
19
|
-
print(f
|
|
21
|
+
print(f"{msg}")
|
|
20
22
|
|
|
21
23
|
def error(self, msg):
|
|
22
|
-
print(f
|
|
24
|
+
print(f"{msg}")
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
class MediaDownloader:
|
|
@@ -30,17 +32,17 @@ class MediaDownloader:
|
|
|
30
32
|
self.audio = False
|
|
31
33
|
|
|
32
34
|
def open_file(self, file):
|
|
33
|
-
youtube_urls = open(file,
|
|
35
|
+
youtube_urls = open(file, "r")
|
|
34
36
|
for url in youtube_urls:
|
|
35
37
|
self.links.append(url)
|
|
36
38
|
self.links = list(dict.fromkeys(self.links))
|
|
37
39
|
|
|
38
|
-
def get_save_path(self):
|
|
40
|
+
def get_save_path(self) -> str:
|
|
39
41
|
return self.download_directory
|
|
40
42
|
|
|
41
43
|
def set_save_path(self, download_directory):
|
|
42
44
|
self.download_directory = download_directory
|
|
43
|
-
self.download_directory = self.download_directory.replace(os.sep,
|
|
45
|
+
self.download_directory = self.download_directory.replace(os.sep, "/")
|
|
44
46
|
|
|
45
47
|
def reset_links(self):
|
|
46
48
|
print("Links Reset")
|
|
@@ -56,7 +58,7 @@ class MediaDownloader:
|
|
|
56
58
|
self.links.append(url)
|
|
57
59
|
self.links = list(dict.fromkeys(self.links))
|
|
58
60
|
|
|
59
|
-
def get_links(self):
|
|
61
|
+
def get_links(self) -> List[str]:
|
|
60
62
|
return self.links
|
|
61
63
|
|
|
62
64
|
def set_audio(self, audio=False):
|
|
@@ -72,62 +74,68 @@ class MediaDownloader:
|
|
|
72
74
|
self.reset_links()
|
|
73
75
|
|
|
74
76
|
def download_video(self, link):
|
|
75
|
-
outtmpl = f
|
|
77
|
+
outtmpl = f"{self.download_directory}/%(uploader)s - %(title)s.%(ext)s"
|
|
76
78
|
if "rumble.com" in link:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
rumble_url = requests.get(link)
|
|
80
|
+
for rumble_embedded_url in rumble_url.text.split(","):
|
|
81
|
+
if "embedUrl" in rumble_embedded_url:
|
|
82
|
+
rumble_embedded_url = re.sub(
|
|
83
|
+
'"', "", re.sub('"embedUrl":', "", rumble_embedded_url)
|
|
84
|
+
)
|
|
85
|
+
link = rumble_embedded_url
|
|
86
|
+
outtmpl = f"{self.download_directory}/%(title)s.%(ext)s"
|
|
83
87
|
|
|
84
88
|
if self.audio:
|
|
85
89
|
ydl_opts = {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
"format": "bestaudio/best",
|
|
91
|
+
"postprocessors": [
|
|
92
|
+
{
|
|
93
|
+
"key": "FFmpegExtractAudio",
|
|
94
|
+
"preferredcodec": "mp3",
|
|
95
|
+
"preferredquality": "320",
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"progress_with_newline": True,
|
|
99
|
+
"logger": StdOutLogger(),
|
|
100
|
+
"outtmpl": outtmpl,
|
|
95
101
|
}
|
|
96
102
|
else:
|
|
97
103
|
ydl_opts = {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
"format": "best",
|
|
105
|
+
"progress_with_newline": True,
|
|
106
|
+
"logger": StdOutLogger(),
|
|
107
|
+
"outtmpl": outtmpl,
|
|
102
108
|
}
|
|
103
109
|
try:
|
|
104
110
|
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
|
105
111
|
print(ydl.download([link]))
|
|
106
|
-
except Exception
|
|
112
|
+
except Exception:
|
|
107
113
|
try:
|
|
108
114
|
if self.audio:
|
|
109
|
-
outtmpl = f
|
|
115
|
+
outtmpl = f"{self.download_directory}/%(id)s.%(ext)s"
|
|
110
116
|
ydl_opts = {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
"format": "bestaudio/best",
|
|
118
|
+
"progress_with_newline": True,
|
|
119
|
+
"logger": StdOutLogger(),
|
|
120
|
+
"postprocessors": [
|
|
121
|
+
{
|
|
122
|
+
"key": "FFmpegExtractAudio",
|
|
123
|
+
"preferredcodec": "mp3",
|
|
124
|
+
"preferredquality": "320",
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"outtmpl": outtmpl,
|
|
120
128
|
}
|
|
121
129
|
else:
|
|
122
130
|
ydl_opts = {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
"format": "best",
|
|
132
|
+
"progress_with_newline": True,
|
|
133
|
+
"logger": StdOutLogger(),
|
|
134
|
+
"outtmpl": outtmpl,
|
|
127
135
|
}
|
|
128
136
|
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
|
129
137
|
print(ydl.download([link]))
|
|
130
|
-
except Exception
|
|
138
|
+
except Exception:
|
|
131
139
|
print(f"Unable to download video: {link}")
|
|
132
140
|
|
|
133
141
|
def get_channel_videos(self, channel, limit=-1):
|
|
@@ -137,10 +145,11 @@ class MediaDownloader:
|
|
|
137
145
|
while attempts < 3:
|
|
138
146
|
url = f"https://www.youtube.com/user/{username}/videos"
|
|
139
147
|
page = requests.get(url).content
|
|
140
|
-
data = str(page).split(
|
|
148
|
+
data = str(page).split(" ")
|
|
141
149
|
item = 'href="/watch?'
|
|
142
|
-
vids = [
|
|
143
|
-
|
|
150
|
+
vids = [
|
|
151
|
+
line.replace('href="', "youtube.com") for line in data if item in line
|
|
152
|
+
] # list of all videos listed twice
|
|
144
153
|
# print(vids) # index the latest video
|
|
145
154
|
x = 0
|
|
146
155
|
if vids:
|
|
@@ -158,19 +167,21 @@ class MediaDownloader:
|
|
|
158
167
|
print("URL: ", url)
|
|
159
168
|
page = requests.get(url).content
|
|
160
169
|
print("Page: ", page)
|
|
161
|
-
data = str(page).split(
|
|
170
|
+
data = str(page).split(" ")
|
|
162
171
|
print("Data: ", data)
|
|
163
|
-
item =
|
|
172
|
+
item = "https://i.ytimg.com/vi/"
|
|
164
173
|
vids = []
|
|
165
174
|
for line in data:
|
|
166
175
|
if item in line:
|
|
167
176
|
vid = line
|
|
168
|
-
#vid = line.replace('https://i.ytimg.com/vi/', '')
|
|
177
|
+
# vid = line.replace('https://i.ytimg.com/vi/', '')
|
|
169
178
|
try:
|
|
170
|
-
found = re.search(
|
|
179
|
+
found = re.search(
|
|
180
|
+
"https://i.ytimg.com/vi/(.+?)/hqdefault.", vid
|
|
181
|
+
).group(1)
|
|
171
182
|
except AttributeError:
|
|
172
183
|
# AAA, ZZZ not found in the original string
|
|
173
|
-
found =
|
|
184
|
+
found = "" # apply your error handling
|
|
174
185
|
print("Vid, ", vid)
|
|
175
186
|
vid = f"https://www.youtube.com/watch?v={found}"
|
|
176
187
|
vids.append(vid)
|
|
@@ -188,8 +199,11 @@ class MediaDownloader:
|
|
|
188
199
|
x += 1
|
|
189
200
|
else:
|
|
190
201
|
print("Trying Old Method")
|
|
191
|
-
vids = [
|
|
192
|
-
|
|
202
|
+
vids = [
|
|
203
|
+
line.replace('href="', "youtube.com")
|
|
204
|
+
for line in data
|
|
205
|
+
if item in line
|
|
206
|
+
] # list of all videos listed twice
|
|
193
207
|
if vids:
|
|
194
208
|
for vid in vids:
|
|
195
209
|
if limit < 0:
|
|
@@ -206,9 +220,12 @@ class MediaDownloader:
|
|
|
206
220
|
|
|
207
221
|
def media_downloader(argv):
|
|
208
222
|
video_downloader_instance = MediaDownloader()
|
|
209
|
-
audio_only = False
|
|
210
223
|
try:
|
|
211
|
-
opts, args = getopt.getopt(
|
|
224
|
+
opts, args = getopt.getopt(
|
|
225
|
+
argv,
|
|
226
|
+
"hac:d:f:l:",
|
|
227
|
+
["help", "audio", "channel=", "directory=", "file=", "links="],
|
|
228
|
+
)
|
|
212
229
|
except getopt.GetoptError:
|
|
213
230
|
usage()
|
|
214
231
|
sys.exit(2)
|
|
@@ -234,19 +251,21 @@ def media_downloader(argv):
|
|
|
234
251
|
|
|
235
252
|
|
|
236
253
|
def usage():
|
|
237
|
-
print(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
254
|
+
print(
|
|
255
|
+
f"Media-Downloader: A tool to download any video off the internet!\n"
|
|
256
|
+
f"Version: {__version__}\n"
|
|
257
|
+
f"Author: {__author__}\n"
|
|
258
|
+
f"Credits: {__credits__}\n"
|
|
259
|
+
f"\nUsage:\n"
|
|
260
|
+
f"-h | --help [ See usage ]\n"
|
|
261
|
+
f"-a | --audio [ Download audio only ]\n"
|
|
262
|
+
f"-c | --channel [ YouTube Channel/User - Downloads all videos ]\n"
|
|
263
|
+
f"-d | --directory [ Location where the images will be saved ]\n"
|
|
264
|
+
f"-f | --file [ Text file to read the URLs from ]\n"
|
|
265
|
+
f"-l | --links [ Comma separated URLs (No spaces) ]\n"
|
|
266
|
+
f"\nExample:\n"
|
|
267
|
+
f'media-downloader -f "file_of_urls.txt" -l "URL1,URL2,URL3" -c "WhiteHouse" -d "~/Downloads"\n'
|
|
268
|
+
)
|
|
250
269
|
|
|
251
270
|
|
|
252
271
|
def main():
|
media_downloader/version.py
CHANGED
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: media-downloader
|
|
3
|
-
Version: 0.11.
|
|
3
|
+
Version: 0.11.5
|
|
4
4
|
Summary: Download audio/videos from the internet!
|
|
5
5
|
Home-page: https://github.com/Knuckles-Team/media-downloader
|
|
6
6
|
Author: Audel Rouhi
|
|
@@ -42,9 +42,9 @@ Requires-Dist: yt-dlp (>=2023.12.30)
|
|
|
42
42
|

|
|
43
43
|

|
|
44
44
|
|
|
45
|
-
*Version: 0.11.
|
|
45
|
+
*Version: 0.11.5*
|
|
46
46
|
|
|
47
|
-
Download videos and audio from the internet!
|
|
47
|
+
Download videos and audio from the internet!
|
|
48
48
|
|
|
49
49
|
This is a wrapper for the pytube library to simplify downloading from these various sources.
|
|
50
50
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
media_downloader/__init__.py,sha256=NdFVoFJM5ltTmSM7Be2Hfx7u8CHFwdYYw2zciU1Z-Qw,407
|
|
2
|
+
media_downloader/media_downloader.py,sha256=qluLse0xZemaSOTRUqJYXt93M0rqjsiaKM5QGrfZZuk,9570
|
|
3
|
+
media_downloader/version.py,sha256=1ess5zv1cnovCGPWYpp1aH04etqebw86R0ZM9Qt25mo,117
|
|
4
|
+
media_downloader-0.11.5.dist-info/LICENSE,sha256=Z1xmcrPHBnGCETO_LLQJUeaSNBSnuptcDVTt4kaPUOE,1060
|
|
5
|
+
media_downloader-0.11.5.dist-info/METADATA,sha256=ywTWRhvuUOBR7co0UNBrgVUxBttT9mXpezCyU-CdJtg,5228
|
|
6
|
+
media_downloader-0.11.5.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
|
7
|
+
media_downloader-0.11.5.dist-info/entry_points.txt,sha256=ZYFDwE25i9D2Mc_ZkLbA0ASaUJo_IEOGDU2gXO7OQnE,77
|
|
8
|
+
media_downloader-0.11.5.dist-info/top_level.txt,sha256=B2OBmgONOm0hIyx2HJ8qFPOI_p5HOeolrYvmslVC1fc,17
|
|
9
|
+
media_downloader-0.11.5.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
media_downloader/__init__.py,sha256=iCl7rzarsiHgt6a5R_A1aANqNfD5rhJi4Zvj8oQ47zo,348
|
|
2
|
-
media_downloader/media_downloader.py,sha256=w84xa7AZWmjIO_PqSH8KVys4jD4xid194vW_lgkhCQI,9232
|
|
3
|
-
media_downloader/version.py,sha256=nNim2GJuN__8K9sYmX38MUAmcYjhdueCrTO8qIaVPJk,117
|
|
4
|
-
media_downloader-0.11.3.dist-info/LICENSE,sha256=wtI1_YjppxJA2UTLHLbj_goBi-f3DebTfIFbe_XqJmY,1059
|
|
5
|
-
media_downloader-0.11.3.dist-info/METADATA,sha256=_LYaZc5lKbT5sdrIxth5_d0-f0_hW_l3dU8hxQU0cIo,5229
|
|
6
|
-
media_downloader-0.11.3.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
|
7
|
-
media_downloader-0.11.3.dist-info/entry_points.txt,sha256=ZYFDwE25i9D2Mc_ZkLbA0ASaUJo_IEOGDU2gXO7OQnE,77
|
|
8
|
-
media_downloader-0.11.3.dist-info/top_level.txt,sha256=B2OBmgONOm0hIyx2HJ8qFPOI_p5HOeolrYvmslVC1fc,17
|
|
9
|
-
media_downloader-0.11.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|