some linting and readability improvements
This commit is contained in:
parent
84fb419931
commit
a5ba8fbbe2
10
interface.py
10
interface.py
|
@ -8,11 +8,11 @@ from time import sleep
|
|||
|
||||
from src.config import get_config
|
||||
|
||||
import src.tvsort as tvsort
|
||||
import src.moviesort as moviesort
|
||||
import src.db_export as db_export
|
||||
import src.trailers as trailers
|
||||
import src.id_fix as id_fix
|
||||
from src import tvsort
|
||||
from src import moviesort
|
||||
from src import db_export
|
||||
from src import trailers
|
||||
from src import id_fix
|
||||
|
||||
|
||||
class Interface:
|
||||
|
|
|
@ -16,7 +16,7 @@ def get_config():
|
|||
else:
|
||||
config_path = path.join(root_folder, 'config.json')
|
||||
# parse
|
||||
with open(config_path, 'r') as config_file:
|
||||
with open(config_path, 'r', encoding='utf-8') as config_file:
|
||||
data = config_file.read()
|
||||
config = json.loads(data)
|
||||
return config
|
||||
|
|
|
@ -126,7 +126,7 @@ class DatabaseExport:
|
|||
file_path = path.join(log_folder, filename)
|
||||
|
||||
# open and write
|
||||
with open(file_path, 'w') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
# take fieldnames from first line
|
||||
fieldnames = to_write[0].keys()
|
||||
csv_writer = csv.DictWriter(f, fieldnames)
|
||||
|
@ -138,7 +138,7 @@ class DatabaseExport:
|
|||
log_folder = self.CONFIG['media']['log_folder']
|
||||
file_path = path.join(log_folder, filename)
|
||||
# movie by new
|
||||
with open(file_path, 'w') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
for line in to_write:
|
||||
f.write(line + '\n')
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class TrailerHandler:
|
|||
""" read log file to get list of trailers to ignore """
|
||||
log_folder = self.CONFIG['media']['log_folder']
|
||||
log_file = os.path.join(log_folder, 'trailers')
|
||||
with open(log_file, 'r') as log_file:
|
||||
with open(log_file, 'r', encoding='utf-8') as log_file:
|
||||
trailer_lines = log_file.readlines()
|
||||
ignore_trailer_list = []
|
||||
for trailer_line in trailer_lines:
|
||||
|
@ -97,6 +97,7 @@ class TrailerHandler:
|
|||
return pending
|
||||
|
||||
def dl_pending(self):
|
||||
# pylint: disable=broad-except
|
||||
""" download pending trailers """
|
||||
sortpath = self.CONFIG['media']['sortpath']
|
||||
log_folder = self.CONFIG['media']['log_folder']
|
||||
|
@ -121,7 +122,7 @@ class TrailerHandler:
|
|||
if i == 4:
|
||||
# giving up
|
||||
log_file = os.path.join(log_folder, 'trailers')
|
||||
with open(log_file, 'a') as f:
|
||||
with open(log_file, 'a', encoding='utf-8') as f:
|
||||
f.write(f'{youtube_id} {movie_name}\n')
|
||||
break
|
||||
sleep((i + 1) ** 2)
|
||||
|
|
Loading…
Reference in New Issue