-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathytm_extractor.py
executable file
·38 lines (32 loc) · 1.13 KB
/
ytm_extractor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Made by papi
# ytm_extractor.py
# Description:
# Downloads albu, covers from youtube music gallery
# You need to extract all of the links using the network tab in inspector element
# and then load all of your albums by scrolling down then extract the .har file
# and run it through this script to download every album cover to a
# youtube_music_artwork folder.
import urllib
import sys, json, os
data=None
inc=0
try:
os.stat("./youtube_music_artwork")
except:
os.mkdir("./youtube_music_artwork")
if len(sys.argv) != 2:
print "Usage:"
print "\t%s [file].har" % sys.argv[0]
print
print "Program made by papi to download artwork from .har files gathered from youtube music."
sys.exit(-1)
with open(sys.argv[1], "r") as fp:
data = json.load(fp)
for entrie in data["log"]["entries"]:
for headers in entrie["response"]["headers"]:
if headers["name"] == "content-type" and headers["value"] == "image/jpeg":
print entrie["request"]["url"]
urllib.urlretrieve(entrie["request"]["url"], "youtube_music_artwork/%d.jpg" % inc)
inc+=1