Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit e1b10f0

Browse files
committed
Init
0 parents  commit e1b10f0

File tree

14 files changed

+1573
-0
lines changed

14 files changed

+1573
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.vscode
2+
3+
list.txt
4+
list copy.txt
5+
music

Pipfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
questionary = "*"
8+
youtube-search-python = "*"
9+
asyncio = "*"
10+
youtube-dl = "*"
11+
rich = "*"
12+
tqdm = "*"
13+
helium = "*"
14+
selenium = "*"
15+
lxml = "*"
16+
cssselect = "*"
17+
eyed3 = "*"
18+
ytmusicapi = "*"
19+
click = "*"
20+
click-help-colors = "*"
21+
pipreqs = "*"
22+
23+
[dev-packages]

Pipfile.lock

Lines changed: 421 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Whitespace-only changes.

mdl/__init__.py

Whitespace-only changes.

mdl/ask.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from __future__ import unicode_literals
2+
from lxml.cssselect import CSSSelector
3+
from lxml.html import fromstring
4+
import questionary
5+
from rich import print, pretty
6+
from rich.traceback import install
7+
install()
8+
pretty.install()
9+
from rich.progress import track
10+
from rich.console import Console
11+
from rich.prompt import Prompt
12+
console = Console()
13+
14+
15+
def asker():
16+
try:
17+
single_songs = questionary.select(
18+
"How many songs do you want to download?",
19+
choices=[
20+
"One song",
21+
"Multiple Songs"
22+
]
23+
).ask()
24+
25+
if single_songs == "One song":
26+
return [questionary.text("What is the song name").ask()]
27+
else:
28+
input_method = questionary.select(
29+
"Which songs do you want to download?",
30+
choices=[
31+
"Songs, comma seperated",
32+
'List in textfile (1 Song per line)',
33+
'From YTMusic (beta)',
34+
]).ask() # returns value of selection
35+
36+
if input_method == "From YTMusic":
37+
console.print("""[bold red]YT-Music[/bold red].
38+
- Go to your YTMusic liked songs playlist (https://music.youtube.com/playlist?list=LM)
39+
- Make sure you are logged in
40+
- Press Ctrl/Cmd + Shift + i and open the dev tools
41+
- Keep scrolling down until you reach the end of your playlist (Songs will stop loading)
42+
- Copy the all the html markup
43+
- Create a text file and paste the html into it.
44+
""")
45+
if not questionary.confirm("Only continue if you have done the task.").ask():
46+
quit()
47+
file = questionary.path("Where is that file located?").ask()
48+
with open(file, "r", encoding="utf-8") as f:
49+
data = f.read()
50+
h = fromstring(data)
51+
sel = CSSSelector("yt-formatted-string.title.style-scope.ytmusic-responsive-list-item-renderer.complex-string > a.yt-simple-endpoint.style-scope.yt-formatted-string")
52+
songs_list=[e.text for e in sel(h)]
53+
return songs_list
54+
55+
elif input_method=="List in textfile (1 Song per line)":
56+
file = questionary.path("Where is that file located?").ask()
57+
text_file = open(file ,encoding='utf-8')
58+
songs_list = text_file.read().splitlines()
59+
return songs_list
60+
elif input_method=="Songs, comma seperated":
61+
songs_list = questionary.text("Write all songs (comma seperated)").ask().split(",")
62+
return songs_list
63+
except Exception as e:
64+
## eventually change :/
65+
pass

0 commit comments

Comments
 (0)