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

|
|
44
43
|

|
|
45
44
|
|
|
46
|
-
*Version: 0.11.
|
|
45
|
+
*Version: 0.11.4*
|
|
47
46
|
|
|
48
|
-
Download videos and audio from the internet!
|
|
47
|
+
Download videos and audio from the internet!
|
|
49
48
|
|
|
50
49
|
This is a wrapper for the pytube library to simplify downloading from these various sources.
|
|
51
50
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
media_downloader/__init__.py,sha256=NdFVoFJM5ltTmSM7Be2Hfx7u8CHFwdYYw2zciU1Z-Qw,407
|
|
2
|
+
media_downloader/media_downloader.py,sha256=ba0Gwb6F-rwU5gQvNiJEAwwSAZypemWknisCYJFjwkc,9548
|
|
3
|
+
media_downloader/version.py,sha256=t2A8GmmzAMdHlb-dIVO4LBLobVCFAwjTCKZsk9GuqR0,117
|
|
4
|
+
media_downloader-0.11.4.dist-info/LICENSE,sha256=Z1xmcrPHBnGCETO_LLQJUeaSNBSnuptcDVTt4kaPUOE,1060
|
|
5
|
+
media_downloader-0.11.4.dist-info/METADATA,sha256=EbJ6m3vi93K5zEcoNwShChpa-1nuco8w-q5gAFP9HB0,5228
|
|
6
|
+
media_downloader-0.11.4.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
|
7
|
+
media_downloader-0.11.4.dist-info/entry_points.txt,sha256=ZYFDwE25i9D2Mc_ZkLbA0ASaUJo_IEOGDU2gXO7OQnE,77
|
|
8
|
+
media_downloader-0.11.4.dist-info/top_level.txt,sha256=B2OBmgONOm0hIyx2HJ8qFPOI_p5HOeolrYvmslVC1fc,17
|
|
9
|
+
media_downloader-0.11.4.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=yxv0e6afUDKHlFSnywVYTvmSjDdB395pwU3u3FQTpEs,117
|
|
4
|
-
media_downloader-0.11.2.dist-info/LICENSE,sha256=wtI1_YjppxJA2UTLHLbj_goBi-f3DebTfIFbe_XqJmY,1059
|
|
5
|
-
media_downloader-0.11.2.dist-info/METADATA,sha256=6zyM5-n8ZZLgNEgoQd-8gvTSnH_fU3fHpv2uaYbQMwY,5262
|
|
6
|
-
media_downloader-0.11.2.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
|
7
|
-
media_downloader-0.11.2.dist-info/entry_points.txt,sha256=ZYFDwE25i9D2Mc_ZkLbA0ASaUJo_IEOGDU2gXO7OQnE,77
|
|
8
|
-
media_downloader-0.11.2.dist-info/top_level.txt,sha256=B2OBmgONOm0hIyx2HJ8qFPOI_p5HOeolrYvmslVC1fc,17
|
|
9
|
-
media_downloader-0.11.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|