moved default&output files dicts to coub_dl class. closes #2

This commit is contained in:
Kjistóf 2017-10-29 20:25:01 +01:00
parent 2afd93edfb
commit e7c7b06088

View File

@ -31,14 +31,13 @@ class File(Enum):
OUTPUT = 4 OUTPUT = 4
FILES_DICT_DEFAULT = {Stream.AUDIO: 'audio', Stream.VIDEO: 'video',
File.LIST: 'list.txt', File.LOOP: 'loop', File.FRACTION: 'fraction',
File.OUTPUT: 'out'}
OUTPUT_FILES = {File.OUTPUT}
class coub_dl: class coub_dl:
default_files = {Stream.AUDIO: 'audio', Stream.VIDEO: 'video',
File.LIST: 'list.txt', File.LOOP: 'loop', File.FRACTION: 'fraction',
File.OUTPUT: 'out'}
output_files = {File.OUTPUT}
def __init__(self, url, files_dict, directory): def __init__(self, url, files_dict, directory):
self._url = url self._url = url
self._files_dict = files_dict self._files_dict = files_dict
@ -177,7 +176,7 @@ class coub_dl:
def run(URL, output, extension): def run(URL, output, extension):
# create dict that contains files used # create dict that contains files used
FILES = deepcopy(FILES_DICT_DEFAULT) FILES = deepcopy(coub_dl.default_files)
determine_output_filename(URL, output, extension, FILES) determine_output_filename(URL, output, extension, FILES)
# ask what to do if output exists # ask what to do if output exists
@ -193,7 +192,7 @@ def run(URL, output, extension):
# create temporary directory to work in # create temporary directory to work in
with temporary_directory() as dir: with temporary_directory() as dir:
# update temporary file locations in FILES dict # update temporary file locations in FILES dict
for key in {key: FILES[key] for key in FILES if key not in OUTPUT_FILES}: for key in {key: FILES[key] for key in FILES if key not in coub_dl.output_files}:
FILES[key] = join(dir, FILES[key]) FILES[key] = join(dir, FILES[key])
coub_dl(URL, FILES, dir)() coub_dl(URL, FILES, dir)()