From 116d6f02393927b811226052e318999fea61bf13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Mon, 30 Oct 2017 19:31:18 +0100 Subject: [PATCH] removed redundant directory parameter from coub_dl.__init__() --- coub-dl.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/coub-dl.py b/coub-dl.py index 7010d21..dc00faa 100755 --- a/coub-dl.py +++ b/coub-dl.py @@ -7,7 +7,7 @@ from subprocess import call, Popen, PIPE, DEVNULL from os import listdir, remove -from os.path import splitext, exists, join +from os.path import splitext, exists, join, split from re import match from enum import Enum from datetime import timedelta @@ -43,10 +43,9 @@ class coub_dl: output_files = {File.OUTPUT} - def __init__(self, url, files_dict, directory): + def __init__(self, url, files_dict): self._url = url self._files_dict = files_dict - self._directory = directory self._loopdata = namedtuple('loopdata', ('base', 'fraction', 'time', 'file')) @@ -83,11 +82,11 @@ class coub_dl: def read_extensions(self): - for file in listdir(self._directory): - for filename in self._files_dict: - fullname = join(self._directory, file) - if match('^{}\..+$'.format(self._files_dict[filename]), fullname): - self._files_dict[filename] = fullname + for stream in {Stream.AUDIO, Stream.VIDEO}: + sdir, sfile = split(self._files_dict[stream]) + for file in listdir(sdir): + if match('^{}\..+$'.format(sfile), file): + self._files_dict[stream] = join(sdir, file) def check_downloads(self): @@ -195,7 +194,7 @@ def run(URL, output, extension): for key in {key: FILES[key] for key in FILES if key not in coub_dl.output_files}: FILES[key] = join(tempdir, FILES[key]) - coub_dl(URL, FILES, tempdir)() + coub_dl(URL, FILES)() def determine_output_filename(url, user_supplied, extension, files_dict):