cute messages

This commit is contained in:
Hellow 2023-04-04 20:19:29 +02:00
parent 8b10b4e4ca
commit 6e83f3fdc2
2 changed files with 61 additions and 37 deletions

View File

@ -1,20 +1,10 @@
import gc import gc
from pathlib import Path
from typing import List
import musicbrainzngs import musicbrainzngs
import logging import logging
import re import re
from . import ( from . import objects, pages
objects, from .utils.shared import MUSIC_DIR, NOT_A_GENRE, get_random_message
pages
)
from .utils.shared import (
MUSIC_DIR,
NOT_A_GENRE
)
""" """
@ -42,49 +32,62 @@ DOWNLOAD_COMMANDS = {
"hs" "hs"
} }
EXIT_COMMANDS = {
"exit",
"quit"
}
def cli(): 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() query: str = query.strip()
parsed: str = query.lower() parsed: str = query.lower()
if parsed in EXIT_COMMANDS:
return True
if parsed == ".": if parsed == ".":
return return False
if parsed == "..": if parsed == "..":
search.goto_previous() search.goto_previous()
return return False
if parsed.isdigit(): if parsed.isdigit():
search.choose_index(int(parsed)) search.choose_index(int(parsed))
return return False
if parsed in DOWNLOAD_COMMANDS: if parsed in DOWNLOAD_COMMANDS:
print(search.download_chosen()) r = search.download_chosen()
print()
print(r)
return True
url = re.match(URL_REGGEX, query) url = re.match(URL_REGGEX, query)
if url is not None: if url is not None:
if not search.search_url(url.string): if not search.search_url(url.string):
print("The given url couldn't be downloaded") print("The given url couldn't be found.")
return return False
page = search.get_page_from_query(parsed) page = search.get_page_from_query(parsed)
if page is not None: if page is not None:
search.choose_page(page) search.choose_page(page)
return return False
# if everything else is not valid search # if everything else is not valid search
search.search(query) search.search(query)
return False
search = pages.Search() search = pages.Search()
while True: while True:
next_input = input(">> ") if next_search(search, input(">> ")):
if next_input in {
"exit",
"quit"
}:
print("byeeee UwU")
break break
next_search(search, next_input)
print(search) print(search)
print()
print(get_random_message())

View File

@ -1,14 +1,36 @@
import musicbrainzngs from typing import List
import logging import logging
import tempfile import tempfile
import os import os
import configparser import configparser
from sys import platform as current_os from sys import platform as current_os
from pathlib import Path 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" LOG_FILE = "download_logs.log"
TEMP_DATABASE_FILE = "metadata.db"
TEMP_DIR = Path(tempfile.gettempdir(), "music-downloader") TEMP_DIR = Path(tempfile.gettempdir(), "music-downloader")
TEMP_DIR.mkdir(exist_ok=True) TEMP_DIR.mkdir(exist_ok=True)
@ -55,9 +77,9 @@ if current_os == "linux":
except (FileNotFoundError, KeyError) as E: except (FileNotFoundError, KeyError) as E:
logger.warning( logger.warning(
f"Missing file or No entry found for \"xdg_music_dir\" in: \"{XDG_USER_DIRS_FILE}\".\n" \ 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"Will fallback on default \"$HOME/Music\"."
) )
TOR = False TOR = False
proxies = { proxies = {
@ -65,7 +87,6 @@ proxies = {
'https': 'socks5h://127.0.0.1:9150' 'https': 'socks5h://127.0.0.1:9150'
} if TOR else {} } if TOR else {}
""" """
available variables: available variables:
- genre - genre