Skip to content

Commit

Permalink
Merge pull request #20 from WhiteyDude/master
Browse files Browse the repository at this point in the history
Fixed broken cookie YoutubeDL option, added debug logging flag
  • Loading branch information
whatdaybob authored Apr 8, 2022
2 parents 74936fd + d3854ba commit 966e42a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions app/sonarr_youtubedl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
import schedule
import time
import logging
import argparse

# allow debug arg for verbose logging
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--debug', action='store_true', help='Enable debug logging')
args = parser.parse_args()

# setup logger
logger = setup_logging()
logger = setup_logging(True, True, args.debug)

date_format = "%Y-%m-%dT%H:%M:%SZ"
now = datetime.now()
Expand Down Expand Up @@ -255,7 +260,7 @@ def appendcookie(self, ytdlopts, cookies=None):
cookie_exists = os.path.exists(cookie_path)
if cookie_exists is True:
ytdlopts.update({
'cookie': cookie_path
'cookiefile': cookie_path
})
# if self.debug is True:
logger.debug(' Cookies file used: {}'.format(cookie_path))
Expand Down
10 changes: 5 additions & 5 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ def ytdl_hooks(d):
file_tuple = os.path.split(os.path.abspath(d['filename']))
logger.info(" Downloaded - {}".format(file_tuple[1]))

def setup_logging(lf_enabled=True, lc_enabled=True, debugging=False):

def setup_logging(lf_enabled=True, lc_enabled=True):

log_level = logging.DEBUG if debugging == True else log_level
logger = logging.getLogger('sonarr_youtubedl')
logger.setLevel(logging.INFO)
logger.setLevel(log_level)
log_format = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

if lf_enabled:
Expand All @@ -145,15 +145,15 @@ def setup_logging(lf_enabled=True, lc_enabled=True):
maxBytes=5000000,
backupCount=5
)
loggerfile.setLevel(logging.INFO)
loggerfile.setLevel(log_level)
loggerfile.set_name('FileHandler')
loggerfile.setFormatter(log_format)
logger.addHandler(loggerfile)

if lc_enabled:
# setup console log
loggerconsole = logging.StreamHandler()
loggerconsole.setLevel(logging.INFO)
loggerconsole.setLevel(log_level)
loggerconsole.set_name('StreamHandler')
loggerconsole.setFormatter(log_format)
logger.addHandler(loggerconsole)
Expand Down

0 comments on commit 966e42a

Please sign in to comment.