Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Youtube-2-mp3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Louis Devillez
Youtube-2-mp3
Commits
0d12f661
Commit
0d12f661
authored
6 years ago
by
Louis Devillez
Browse files
Options
Downloads
Patches
Plain Diff
V1.0
parent
5dd5523f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
main.py
+48
-0
48 additions, 0 deletions
main.py
settings.py
+5
-0
5 additions, 0 deletions
settings.py
with
54 additions
and
1 deletion
README.md
+
1
−
1
View file @
0d12f661
# Youtube-2-mp3
# Youtube-2-mp3
Download song from youtube directly into your folders
From one key press, you download the youtube video from your browser.
This diff is collapsed.
Click to expand it.
main.py
0 → 100644
+
48
−
0
View file @
0d12f661
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
=
f
.
read
(
8
)
jdata
=
json
.
loads
(
lz4
.
block
.
decompress
(
f
.
read
()).
decode
(
"
utf-8
"
))
f
.
close
()
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
"
www.youtube.com
"
in
urls
:
list
.
append
(
URLS
,
urls
)
for
i
in
URLS
:
video_id
=
parse_qs
(
urlparse
(
i
).
query
)[
'
v
'
][
0
]
url_data
=
urlopen
(
'
http://www.youtube.com/get_video_info?&video;_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
)
print
(
info_dict
[
"
title
"
])
title
=
input
(
"
Titre de la musique:
"
)
ydl
.
download
([
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
"
)
This diff is collapsed.
Click to expand it.
settings.py
0 → 100644
+
5
−
0
View file @
0d12f661
settings
=
{
"
browser
"
:
"
firefox
"
,
"
path
"
:
"
/home/westornd/.mozilla/firefox/euy0mqkl.default/sessionstore-backups
"
,
"
pathMusique
"
:
"
/home/westornd/Musique
"
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment