Commit 0d12f661 authored by Louis Devillez's avatar Louis Devillez
Browse files


parent 5dd5523f
# Youtube-2-mp3
Download song from youtube directly into your folders
From one key press, you download the youtube video from your browser.
from __future__ import unicode_literals
import os
import json
import lz4.block
import requests
import youtube_dl
from urllib.request import urlopen, FancyURLopener
from urllib.parse import urlparse, parse_qs, unquote
from settings import settings
f = open(settings["path"] + "/recovery.jsonlz4", "rb")
magic =
jdata = json.loads(lz4.block.decompress("utf-8"))
URLS = []
for win in jdata.get("windows"):
for tab in win.get("tabs"):
i = tab.get("index") - 1
urls = tab.get("entries")[i].get("url")
if "" in urls:
for i in URLS:
video_id = parse_qs(urlparse(i).query)['v'][0]
url_data = urlopen(';_id=' + video_id).read()
url_info = parse_qs(unquote(url_data.decode('utf-8')))
ydl_opts = {
'format': 'bestaudio/best',
'forcetitle': 'true',
'forcejson': 'true',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info_dict = ydl.extract_info(i, download=False)
title = input("Titre de la musique: ")[i])
dir = os.listdir(settings["pathMusique"])
for i in range(0,len(dir)):
print(str(i) + " - " + dir[i])
dirFinal = dir[int(input("Dossier final:"))]
os.rename(info_dict["title"]+'-' +info_dict["id"]+".mp3",settings["pathMusique"] + '/'+ dirFinal +'/' + title +".mp3")
settings= {
"pathMusique": "/home/westornd/Musique"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment