cute messages
This commit is contained in:
parent
8b10b4e4ca
commit
6e83f3fdc2
@ -1,20 +1,10 @@
|
||||
import gc
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
import musicbrainzngs
|
||||
import logging
|
||||
import re
|
||||
|
||||
from . import (
|
||||
objects,
|
||||
pages
|
||||
)
|
||||
|
||||
|
||||
from .utils.shared import (
|
||||
MUSIC_DIR,
|
||||
NOT_A_GENRE
|
||||
)
|
||||
from . import objects, pages
|
||||
from .utils.shared import MUSIC_DIR, NOT_A_GENRE, get_random_message
|
||||
|
||||
|
||||
"""
|
||||
@ -42,49 +32,62 @@ DOWNLOAD_COMMANDS = {
|
||||
"hs"
|
||||
}
|
||||
|
||||
EXIT_COMMANDS = {
|
||||
"exit",
|
||||
"quit"
|
||||
}
|
||||
|
||||
|
||||
def cli():
|
||||
def next_search(search: pages.Search, query: str):
|
||||
def next_search(search: pages.Search, query: str) -> bool:
|
||||
"""
|
||||
:param search:
|
||||
:param query:
|
||||
:return exit in the next step:
|
||||
"""
|
||||
query: str = query.strip()
|
||||
parsed: str = query.lower()
|
||||
|
||||
if parsed in EXIT_COMMANDS:
|
||||
return True
|
||||
|
||||
if parsed == ".":
|
||||
return
|
||||
return False
|
||||
if parsed == "..":
|
||||
search.goto_previous()
|
||||
return
|
||||
return False
|
||||
|
||||
if parsed.isdigit():
|
||||
search.choose_index(int(parsed))
|
||||
return
|
||||
return False
|
||||
|
||||
if parsed in DOWNLOAD_COMMANDS:
|
||||
print(search.download_chosen())
|
||||
r = search.download_chosen()
|
||||
print()
|
||||
print(r)
|
||||
return True
|
||||
|
||||
url = re.match(URL_REGGEX, query)
|
||||
if url is not None:
|
||||
if not search.search_url(url.string):
|
||||
print("The given url couldn't be downloaded")
|
||||
return
|
||||
print("The given url couldn't be found.")
|
||||
return False
|
||||
|
||||
page = search.get_page_from_query(parsed)
|
||||
if page is not None:
|
||||
search.choose_page(page)
|
||||
return
|
||||
return False
|
||||
|
||||
# if everything else is not valid search
|
||||
search.search(query)
|
||||
|
||||
return False
|
||||
|
||||
search = pages.Search()
|
||||
|
||||
while True:
|
||||
next_input = input(">> ")
|
||||
if next_input in {
|
||||
"exit",
|
||||
"quit"
|
||||
}:
|
||||
print("byeeee UwU")
|
||||
if next_search(search, input(">> ")):
|
||||
break
|
||||
next_search(search, next_input)
|
||||
print(search)
|
||||
|
||||
|
||||
print()
|
||||
print(get_random_message())
|
||||
|
@ -1,14 +1,36 @@
|
||||
import musicbrainzngs
|
||||
from typing import List
|
||||
import logging
|
||||
import tempfile
|
||||
import os
|
||||
import configparser
|
||||
from sys import platform as current_os
|
||||
from pathlib import Path
|
||||
import random
|
||||
|
||||
"""
|
||||
I will now and then use those messages in the programm.
|
||||
But I won't overuse them dw.
|
||||
|
||||
I will keep those messages, if you disagree with me on the messages,
|
||||
feel free to fork the programm and edit them, or just edit them in the config
|
||||
file once I implemented it.
|
||||
"""
|
||||
HAPPY_MESSAGES: List[str] = [
|
||||
"Support the artist.",
|
||||
"Star Me: https://github.com/HeIIow2/music-downloader",
|
||||
"🏳️⚧️🏳️⚧️ Trans rights are human rights. 🏳️⚧️🏳️⚧️",
|
||||
"🏳️⚧️🏳️⚧️ Trans women are women, trans men are men. 🏳️⚧️🏳️⚧️",
|
||||
"🏴☠️🏴☠️ Unite under one flag, fuck borders. 🏴☠️🏴☠️",
|
||||
"Join my Matrix Space: https://matrix.to/#/#music-kraken:matrix.org",
|
||||
"Gotta love BPJM!! :/"
|
||||
]
|
||||
|
||||
|
||||
def get_random_message() -> str:
|
||||
return random.choice(HAPPY_MESSAGES)
|
||||
|
||||
|
||||
LOG_FILE = "download_logs.log"
|
||||
TEMP_DATABASE_FILE = "metadata.db"
|
||||
TEMP_DIR = Path(tempfile.gettempdir(), "music-downloader")
|
||||
TEMP_DIR.mkdir(exist_ok=True)
|
||||
|
||||
@ -52,20 +74,19 @@ if current_os == "linux":
|
||||
config.read_string(data)
|
||||
xdg_config = config['XDG_USER_DIRS']
|
||||
MUSIC_DIR = os.path.expandvars(xdg_config['xdg_music_dir'].strip('"'))
|
||||
|
||||
|
||||
except (FileNotFoundError, KeyError) as E:
|
||||
logger.warning(
|
||||
f"Missing file or No entry found for \"xdg_music_dir\" in: \"{XDG_USER_DIRS_FILE}\".\n" \
|
||||
f"Will fallback on default \"$HOME/Music\"."
|
||||
)
|
||||
|
||||
f"Missing file or No entry found for \"xdg_music_dir\" in: \"{XDG_USER_DIRS_FILE}\".\n" \
|
||||
f"Will fallback on default \"$HOME/Music\"."
|
||||
)
|
||||
|
||||
TOR = False
|
||||
proxies = {
|
||||
'http': 'socks5h://127.0.0.1:9150',
|
||||
'https': 'socks5h://127.0.0.1:9150'
|
||||
} if TOR else {}
|
||||
|
||||
|
||||
"""
|
||||
available variables:
|
||||
- genre
|
||||
|
Loading…
Reference in New Issue
Block a user