Skip to content

Commit

Permalink
Code Quality fixes (PyLint) for yt_manager.py
Browse files Browse the repository at this point in the history
  • Loading branch information
j54j6 committed May 12, 2024
1 parent 6aaf5bc commit fc3d7fd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
14 changes: 7 additions & 7 deletions project_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,19 @@ def validate_scheme(url, scheme, silent=False):
logging.error("Provided Scheme is not valid! - Check log")
return False

parsedUurl = tldextract.extract(url)
parsedUrl = tldextract.extract(url)
#Check if the provided url matches the filter of the given scheme
if not parsedUurl.suffix in scheme["url_scheme"]["tld"]:
if not parsedUrl.suffix in scheme["url_scheme"]["tld"]:
if not silent:
logging.error(f"Provided url does not match the requirements for the {parsedUurl.domain} scheme! - TLD '{parsedUurl.suffix}' is not supported! - scheme name: {scheme["schema_name"]}")
logging.error("Provided url does not match the requirements for the %s scheme! - TLD '%s' is not supported! - scheme name: %s", parsedUrl.domain, parsedUrl.suffix, scheme["schema_name"])
return False
if not parsedUurl.domain in scheme["url_scheme"]["sld"]:
if not parsedUrl.domain in scheme["url_scheme"]["sld"]:
if not silent:
logging.error(f"Provided url does not match the requirements for the {parsedUurl.domain} scheme! - SLD '{parsedUurl.domain}' is not supported! - scheme name: {scheme["schema_name"]}")
logging.error("Provided url does not match the requirements for the %s scheme! - SLD '%s' is not supported! - scheme name: %s", parsedUrl.domain, parsedUrl.domain, scheme["schema_name"])
return False
if not parsedUurl.subdomain in scheme["url_scheme"]["subd"]:
if not parsedUrl.subdomain in scheme["url_scheme"]["subd"]:
if not silent:
logging.error(f"Provided url does not match the requirements for the {parsedUurl.domain} scheme! - Subdomain '{parsedUurl.subdomain}' is not supported! - scheme name: {scheme["schema_name"]}")
logging.error("Provided url does not match the requirements for the %s scheme! - Subdomain '%s' is not supported! - scheme name: %s", parsedUrl.domain, parsedUrl.subdomain, scheme["schema_name"])
return False
return True

Expand Down
43 changes: 23 additions & 20 deletions yt_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

"""
#
# Project by j54j6
# This program is used to make a private copy of youtube videos and potentially
Expand All @@ -17,6 +18,8 @@
# In general this projects is made out of different modules (see ReadME ).
# This file combines them...
#
"""


# Python Modules
import logging
Expand All @@ -37,43 +40,43 @@
logger.info("Running startup checks...")

#Check for config File
configLoaded = check_for_config()
if not configLoaded:
ConfigLoaded = check_for_config()
if not ConfigLoaded:
logger.error("Error while loading config! - Check log...")
sys.exit()

#Check for database and init
databaseCheckSuccessful = check_db()
if not databaseCheckSuccessful:
DatabaseCheckSuccessful = check_db()
if not DatabaseCheckSuccessful:
logging.error("Error while initializing DB! - Please check log...")
sys.exit()

#Check database content
dependencies = scheme_setup()
Dependencies = scheme_setup()

if not dependencies:
if not Dependencies:
logging.error("Error while prepare dependencies... Check log.")
sys.exit()

#All Tables exists needed to run this thing...
logging.info("All mandatory tables are existing...")

#POSTPONED
#POSTPONED
#parser = argparse.ArgumentParser(
#description="""YT-DL Manager - Download and manage Videos from different sources.
#description="""YT-DL Manager - Download and manage Videos from different sources.
# Further you can download new content completly automatic""")
#parser.add_argument("command",
# type=str,
# choices=["help",
# "add-subscription",
# "del-subscription",
# "list-subscriptions",
# "custom",
# "start",
# "validate"],
#parser.add_argument("command",
# type=str,
# choices=["help",
# "add-subscription",
# "del-subscription",
# "list-subscriptions",
# "custom",
# "start",
# "validate"],
#help="Command - What do you want to do?")
#parser.add_argument("--url",
# help="Url to add a subscription or directly download a video",
#parser.add_argument("--url",
# help="Url to add a subscription or directly download a video",
# default=None)

#args = parser.parse_args()
Expand Down Expand Up @@ -111,6 +114,6 @@
sys.exit()
case "validate":
#Rehash all files and compare them to the already stored files.
sys.sys.exit()
sys.exit()
else:
show_help()

0 comments on commit fc3d7fd

Please sign in to comment.