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 hashlib
import logging
import glob
import os
@ -29,13 +29,10 @@ def reset_config(config_file):
logging.info(f"{YELLOW}Creating config file: {config_file}")
config = configparser.ConfigParser()
config["DEFAULT"]["email"] = input("Enter your email:\n- ")
config["DEFAULT"]["password"] = base64.b64encode(
input("Enter your password\n- ").encode()
).decode()
password = input("Enter your password\n- ")
config["DEFAULT"]["password"] = hashlib.md5(password.encode("utf-8")).hexdigest()
config["DEFAULT"]["default_folder"] = (
input(
"Folder for downloads (leave empy for default 'Qobuz Downloads')\n- "
)
input("Folder for downloads (leave empy for default 'Qobuz Downloads')\n- ")
or "Qobuz Downloads"
)
config["DEFAULT"]["default_quality"] = (
@ -89,7 +86,7 @@ def main():
try:
email = config["DEFAULT"]["email"]
password = base64.b64decode(config["DEFAULT"]["password"]).decode()
password = config["DEFAULT"]["password"]
default_folder = config["DEFAULT"]["default_folder"]
default_limit = config["DEFAULT"]["default_limit"]
default_quality = config["DEFAULT"]["default_quality"]
@ -133,9 +130,8 @@ def main():
quality_fallback=not arguments.no_fallback or not no_fallback,
cover_og_quality=arguments.og_cover or og_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)
try:

View File

@ -184,12 +184,17 @@ class QobuzDL:
def download_from_txt_file(self, txt_file):
with open(txt_file, "r") as txt:
try:
urls = txt.read().strip().split()
urls = [
line.replace("\n", "")
for line in txt.readlines()
if not line.strip().startswith("#")
]
except Exception as e:
logger.error(f"{RED}Invalid text file: {e}")
return
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)

View File

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