Skip to content
Snippets Groups Projects
Commit d7ea73cd authored by Hector Blondel's avatar Hector Blondel
Browse files

ajout des noms

parent 5b1c8a17
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ os.chdir("/mnt/usb/bleezrdata") ...@@ -15,7 +15,7 @@ os.chdir("/mnt/usb/bleezrdata")
t = time() t = time()
while True : while True :
tt = time() tt = time()
if tt - t > 3600. : if tt - t > 60. :
print("actualisation ...") print("actualisation ...")
os.system('sudo echo "\n la dernière actualisation date de : " >> history.txt') os.system('sudo echo "\n la dernière actualisation date de : " >> history.txt')
...@@ -35,31 +35,46 @@ while True : ...@@ -35,31 +35,46 @@ while True :
os.mkdir("contents") os.mkdir("contents")
with open("seen.json",'w') as f : with open("seen.json",'w') as f :
f.write("[]") f.write("[]")
with open("seen_names.json") as f :
f.write("[]")
os.chdir("../..") os.chdir("../..")
#A supprimer lorsque tout le code aura été fait proprement
if "seen_names.json" not in os.listdir("musics/contents"):
with open("seen_names.json") as f :
f.write("[]")
os.chdir("musics/"+playlist) os.chdir("musics/"+playlist)
chn = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId='+playlist+'&key='+KEY chn = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId='+playlist+'&key='+KEY
requete = get(chn) requete = get(chn)
dico = requete.json() dico = requete.json()
all_videos = [x['snippet']['resourceId']['videoId'] for x in dico['items']] all_videos = [x['snippet']['resourceId']['videoId'] for x in dico['items']]
all_videos_names = [x['snippet']['title'] for x in dico['items']]
with open('seen.json','r') as f2 : with open('seen.json','r') as f2 :
seen_videos = load(f2) seen_videos = load(f2)
with open('seen_names.json','r') as f3 :
seen_videos_names = load(f3)
os.chdir("contents") os.chdir("contents")
i = 0 i = 0
while i < len(all_videos) and all_videos[i] not in seen_videos : while i < len(all_videos) and all_videos[i] not in seen_videos :
vid = all_videos[i] vid = all_videos[i]
vid_name = all_videos_names[i]
print(vid) print(vid)
command = "yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v={0} -o '%(title)s.mp3' ".format(vid) command = "yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v={0} -o '%(title)s.mp3' ".format(vid)
os.system(command) os.system(command)
seen_videos.append(vid) seen_videos.append(vid)
seen_videos_names.append(vid_name)
i += 1 i += 1
os.chdir("../") os.chdir("../")
with open('seen.json','w') as f2 : with open('seen.json','w') as f2 :
f2.write(dumps(seen_videos)) f2.write(dumps(seen_videos))
with open('seen_names.json','w') as f :
f.write(dumps(seen_videos_names))
os.chdir("../") os.chdir("../")
os.chdir("../") os.chdir("../")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment