Use hashlib with passwords (close #48); add comments support for text files (close #47)

This commit is contained in:
vitiko98 2021-01-01 16:06:11 -04:00
parent bba6f3a71a
commit b8e68e2bf3
3 changed files with 14 additions and 13 deletions

View File

@ -1,5 +1,5 @@
import base64
import configparser import configparser
import hashlib
import logging import logging
import glob import glob
import os import os
@ -29,13 +29,10 @@ def reset_config(config_file):
logging.info(f"{YELLOW}Creating config file: {config_file}") logging.info(f"{YELLOW}Creating config file: {config_file}")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config["DEFAULT"]["email"] = input("Enter your email:\n- ") config["DEFAULT"]["email"] = input("Enter your email:\n- ")
config["DEFAULT"]["password"] = base64.b64encode( password = input("Enter your password\n- ")
input("Enter your password\n- ").encode() config["DEFAULT"]["password"] = hashlib.md5(password.encode("utf-8")).hexdigest()
).decode()
config["DEFAULT"]["default_folder"] = ( config["DEFAULT"]["default_folder"] = (
input( input("Folder for downloads (leave empy for default 'Qobuz Downloads')\n- ")
"Folder for downloads (leave empy for default 'Qobuz Downloads')\n- "
)
or "Qobuz Downloads" or "Qobuz Downloads"
) )
config["DEFAULT"]["default_quality"] = ( config["DEFAULT"]["default_quality"] = (
@ -89,7 +86,7 @@ def main():
try: try:
email = config["DEFAULT"]["email"] email = config["DEFAULT"]["email"]
password = base64.b64decode(config["DEFAULT"]["password"]).decode() password = config["DEFAULT"]["password"]
default_folder = config["DEFAULT"]["default_folder"] default_folder = config["DEFAULT"]["default_folder"]
default_limit = config["DEFAULT"]["default_limit"] default_limit = config["DEFAULT"]["default_limit"]
default_quality = config["DEFAULT"]["default_quality"] default_quality = config["DEFAULT"]["default_quality"]
@ -133,9 +130,8 @@ def main():
quality_fallback=not arguments.no_fallback or not no_fallback, quality_fallback=not arguments.no_fallback or not no_fallback,
cover_og_quality=arguments.og_cover or og_cover, cover_og_quality=arguments.og_cover or og_cover,
no_cover=arguments.no_cover or no_cover, no_cover=arguments.no_cover or no_cover,
downloads_db=None if no_database or arguments.no_db else QOBUZ_DB downloads_db=None if no_database or arguments.no_db else QOBUZ_DB,
) )
qobuz.initialize_client(email, password, app_id, secrets) qobuz.initialize_client(email, password, app_id, secrets)
try: try:

View File

@ -184,12 +184,17 @@ class QobuzDL:
def download_from_txt_file(self, txt_file): def download_from_txt_file(self, txt_file):
with open(txt_file, "r") as txt: with open(txt_file, "r") as txt:
try: try:
urls = txt.read().strip().split() urls = [
line.replace("\n", "")
for line in txt.readlines()
if not line.strip().startswith("#")
]
except Exception as e: except Exception as e:
logger.error(f"{RED}Invalid text file: {e}") logger.error(f"{RED}Invalid text file: {e}")
return return
logger.info( logger.info(
f'{YELLOW}qobuz-dl will download {len(urls)} urls from file: "{txt_file}"' f"{YELLOW}qobuz-dl will download {len(urls)}"
f" urls from file: {txt_file}"
) )
self.download_list_of_urls(urls) self.download_list_of_urls(urls)

View File

@ -13,7 +13,7 @@ requirements = read_file("requirements.txt").strip().split()
setup( setup(
name=pkg_name, name=pkg_name,
version="0.9.0", version="0.9.1",
author="Vitiko", author="Vitiko",
author_email="vhnz98@gmail.com", author_email="vhnz98@gmail.com",
description="The complete Lossless and Hi-Res music downloader for Qobuz", description="The complete Lossless and Hi-Res music downloader for Qobuz",