diff --git a/.download_server.py.swn b/.download_server.py.swn new file mode 100644 index 0000000000000000000000000000000000000000..271a9b0540f38482974f61781a2d19905e72e4aa Binary files /dev/null and b/.download_server.py.swn differ diff --git a/.download_server.py.swp b/.download_server.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..35d480cb2629cff47796454dd28335336bea56e7 Binary files /dev/null and b/.download_server.py.swp differ diff --git a/__pycache__/credentials.cpython-37.pyc b/__pycache__/credentials.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9f01b36daca18f703eb7d2328f5aa591f46fab16 Binary files /dev/null and b/__pycache__/credentials.cpython-37.pyc differ diff --git a/content.txt b/content.txt new file mode 100644 index 0000000000000000000000000000000000000000..1f8bd379932edb6dced30a81aad1ff67d13645da --- /dev/null +++ b/content.txt @@ -0,0 +1 @@ +PLrclmnNpHHYPQNkNOC-eI89Kx_OMr0Emr diff --git a/copytext.sh b/copytext.sh new file mode 100755 index 0000000000000000000000000000000000000000..e7d18dc4c7c8c6c79789e072ade6191d04fb7e9d --- /dev/null +++ b/copytext.sh @@ -0,0 +1,4 @@ +#!/bin/bash + + +sudo cp -r client/ /mnt/usb/bleezrdata/ diff --git a/credentials.py b/credentials.py new file mode 100644 index 0000000000000000000000000000000000000000..a90ee606d344bee1c7bb5d69610d570a8b36845a --- /dev/null +++ b/credentials.py @@ -0,0 +1 @@ +KEY = "AIzaSyCcUHB9SwOPaOwT7ldOUbQGjfuZx0YZ7v0" diff --git a/credentials.pyc b/credentials.pyc new file mode 100644 index 0000000000000000000000000000000000000000..786f8b91f9ff5e65ee942715f16ce90309dc5f68 Binary files /dev/null and b/credentials.pyc differ diff --git a/download_server.py b/download_server.py index 7c976ca9e7b0d163c21f5fa158f6ef724fd2bb40..addcb06f33070017a73c3a54c734bc7f6261e015 100644 --- a/download_server.py +++ b/download_server.py @@ -6,13 +6,13 @@ from time import time from requests.api import get from json import load,dumps from credentials import KEY - +import unidecode #commande test : "yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v=zA2YBT9z6pA -o '%(id)s.mp3' " -caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+\';!?$%&#~<> " -remplacements = {"(":"-" , ")": "-" , "\"" : "\'","�":"e","�":"a","�":"e","�":"u","�":"e","�":"a","�":"o","�":"o" ,"�":"o","�":"i","�":"u","�":"U","/":" "} +caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+\';!$%&#~<> " +remplacements = {"(":"-" , ")": "-" , "\"" : "\'","/":" "} def replace(caract,remplacements) : if caract in remplacements.keys() : @@ -102,8 +102,8 @@ while True : f.write("[]") os.chdir("musics/"+playlist) - chn = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId='+playlist+'&key='+KEY - print(chn) + chn = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=100&playlistId='+playlist+'&key='+KEY + #print(chn) requete = get(chn) dico = requete.json() all_videos = [x['snippet']['resourceId']['videoId'] for x in dico['items']] @@ -118,7 +118,7 @@ while True : i = 0 while i < len(all_videos) and all_videos[i] not in seen_videos : vid = all_videos[i] - vid_name = garde(remplacer(all_videos_names[i],remplacements),caracteres) + vid_name = garde(remplacer(unidecode.unidecode(all_videos_names[i]),remplacements),caracteres) print(vid) print(vid_name) #command = "yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v={0} -o '%(title)s.mp3' ".format(vid) diff --git a/musics/PL8V2Ld0Is1-kWGtqHFOJiwwnU1lWbpC1r/seen.json b/musics/PL8V2Ld0Is1-kWGtqHFOJiwwnU1lWbpC1r/seen.json deleted file mode 100644 index 90386f950809282daa7250fbbc99bfd8c0b6eddf..0000000000000000000000000000000000000000 --- a/musics/PL8V2Ld0Is1-kWGtqHFOJiwwnU1lWbpC1r/seen.json +++ /dev/null @@ -1 +0,0 @@ -["5kEvVPYOKV0", "GwwsbEjmWjU", "mup5ifEfoa0", "dU-OD5_Dxrs", "JVQTXCh9QTo", "zA2YBT9z6pA", "W3Lh4Pyxxns", "D8zlUUrFK-M", "syG9qMEE8K4", "bBvgjwA4Zns", "5lLVCRmdmMg", "SI80OUiOgOs", "KfHnuSVnp3E", "AUawX5uKiwc", "N7hvKb0voYY", "NwVA5zYfNWw", "yz_wDVLryWY", "wfVqIjfieUU", "OQ6slfP6B8Q", "vhMAhuY4DA8", "Wfck1-gN-3k", "xFrGuyw1V8s", "q9Md17IL41g", "GB_S2qFh5lU", "pnereIT-Nck"] \ No newline at end of file diff --git a/playlists.json b/playlists.json deleted file mode 100644 index a6a779a0898a6a782381ac98dc3d5495de2fd782..0000000000000000000000000000000000000000 --- a/playlists.json +++ /dev/null @@ -1 +0,0 @@ -["PL8V2Ld0Is1-kWGtqHFOJiwwnU1lWbpC1r"] \ No newline at end of file diff --git a/saves/download_server.py b/saves/download_server.py new file mode 100644 index 0000000000000000000000000000000000000000..87b921921feacc25b72444cc12fc55427c9a27d3 --- /dev/null +++ b/saves/download_server.py @@ -0,0 +1,154 @@ +# coding: latin-1 + +import os +from time import time +#from googleapiclient.discovery import build +from requests.api import get +from json import load,dumps +from credentials import KEY + + +#commande test : "yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v=zA2YBT9z6pA -o '%(id)s.mp3' " + + +caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+\';!?$%&#~<> " +remplacements = {"(":"-" , ")": "-" , "\"" : "\'","�":"e","�":"a","�":"e","�":"u","�":"e","�":"a","�":"o","�":"o" ,"�":"o","�":"i","�":"u","�":"U","/":" "} + +def replace(caract,remplacements) : + if caract in remplacements.keys() : + return remplacements[caract] + else : + return caract + +#Supprimer tous les caracteres interdits +def garde(chn,caracteres): + print("filtrage de : "+chn) + res = ("".join([x for x in chn if x in caracteres]) ) + return res + +def remplacer(chn,remplacements): + res = ("".join([replace(x,remplacements) for x in chn])) + print("type(res) : "+ str(type(res)) ) + return res + + + +def addplaylist(playlistid): + os.chdir("/mnt/usb/bleezrdata") + chn = 'https://www.googleapis.com/youtube/v3/playlists?part=snippet&id='+playlistid+'&key='+KEY + dico = get(chn).json() + playlistname = dico["items"][0]["snippet"]["title"] + + + with open("playlistinfo.json",'r') as f : + data = load(f) + + if not playlistid in [x['id'] for x in data] : + data.append({'id':playlistid,'name':playlistname}) + + + with open("playlistinfo.json",'w') as f : + f.write(dumps(data)) + + with open("playlists.json",'r') as f : + data = load(f) + + if not playlistid in data: + data.append(playlistid) + + + with open("playlists.json",'w') as f : + f.write(dumps(data)) + + + +addplaylist("PL8V2Ld0Is1-kUaNtXmvYGtYoyZ0O2aqDt") + +os.chdir("/mnt/usb/bleezrdata") + +t = time() +while True : + tt = time() + if tt - t > 60. : + + print("actualisation ...") + os.system('sudo echo "\n la dernière actualisation date de : " >> history.txt') + os.system('date >> history.txt') + t = tt + with open("playlists.json",'r') as f : + + data = load(f) + for playlist in data : + + if playlist not in os.listdir("musics"): + print("La playlist " + playlist + " n\'est pas dans le repertoire" ) + os.chdir("musics") + + os.mkdir(playlist) + os.chdir(playlist) + #On remplit le dossier de cette playlist + os.mkdir("contents") + with open("seen.json",'w') as f : + f.write("[]") + with open("seen_names.json",'w') as f : + f.write("[]") + + os.chdir("../..") + + #A supprimer lorsque tout le code aura �t� fait proprement + if "seen_names.json" not in os.listdir("musics/"+playlist): + print("seen_names.json n\'est pas dans le r�pertoire de la playlist") + with open("musics/"+playlist+"/seen_names.json",'w') as f : + f.write("[]") + + os.chdir("musics/"+playlist) + chn = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId='+playlist+'&key='+KEY + print(chn) + requete = get(chn) + dico = requete.json() + all_videos = [x['snippet']['resourceId']['videoId'] for x in dico['items']] + all_videos_names = [x['snippet']['title'] for x in dico['items']] + #print("longueur de all_videos : {}".format(len(all_videos))) + with open('seen.json','r') as f2 : + seen_videos = load(f2) + with open('seen_names.json','r') as f3 : + seen_videos_names = load(f3) + + os.chdir("contents") + i = 0 + while i < len(all_videos) and all_videos[i] not in seen_videos : + vid = all_videos[i] + vid_name = garde(remplacer(all_videos_names[i],remplacements),caracteres) + print(vid) + print(vid_name) + #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 \"{1}.mp3\"".format(vid,vid_name) + print(command) + os.system(command) + + if vid_name+".mp3" in os.listdir(".") : + seen_videos.append(vid) + seen_videos_names.append(vid_name) + i += 1 + os.chdir("../") + + with open('seen.json','w') as f2 : + f2.write(dumps(seen_videos)) + + with open('seen_names.json','w') as f : + f.write(dumps(seen_videos_names)) + + os.chdir("../") + os.chdir("../") + +""" +playlist = "PL8V2Ld0Is1-kWGtqHFOJiwwnU1lWbpC1r" +chn = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId='+playlist+'&key='+KEY +requete = get(chn) + + +dico = requete.json() +l = dico['items'] +print([x['snippet']['resourceId']['videoId'] for x in l]) +""" + diff --git a/start.sh.save b/start.sh.save new file mode 100755 index 0000000000000000000000000000000000000000..e57f18c9e47514ce7e1e5fd324dedd8abed90718 --- /dev/null +++ b/start.sh.save @@ -0,0 +1,5 @@ +#!/bin/sh + + +screen -dmS music_downloading python3 download_server.py + diff --git a/start_web.sh b/start_web.sh deleted file mode 100755 index 4a71c10522352f48195831819b1b4bf1b9255492..0000000000000000000000000000000000000000 --- a/start_web.sh +++ /dev/null @@ -1,3 +0,0 @@ -cd /mnt/usb/bleezrdata/musics/ -screen -dmS bleezr_web_server sudo python -m SimpleHTTPServer 8000 -