small fix in ext handeling

This commit is contained in:
simon 2021-04-23 17:40:26 +07:00
parent d790d227d6
commit 89bb00cdfc
3 changed files with 7 additions and 5 deletions

View File

@ -55,7 +55,7 @@ Duplicate the config.sample.json file to a file named *config.json* and set the
* `sortpath`: Empty folder the media_organizer can use to as a temporary sort path.
* `moviepath`: Root folder where the organized movie files will go.
* `tvpath`: Root folder where the organized tv episodes will go.
* `ext`: A space separated list of valid media file extensions to easily filter out none media related files.
* `ext`: A list of valid media file extensions to easily filter out none media related files.
* `log_path`: Path to a folder to output all renaming done to keep track and check for any errors and safe csv files.
* `movie_db_api`: Register and get your themoviedb.com **API Key (v3 auth)** acces from [here](https://www.themoviedb.org/settings/api).

View File

@ -22,10 +22,11 @@ def move_to_sort(movie_downpath, sortpath, ext):
for dirpath, _, filenames in os.walk(movie_downpath):
for filename in filenames:
path = os.path.join(dirpath, filename)
_, extenstion = os.path.splitext(path)
_, extension = os.path.splitext(path)
extension = extension.lstrip('.').lower()
f_size = os.stat(path).st_size
# TODO: set f_size in config.json
if extenstion.lower() in ext and 'sample' not in filename and f_size > 50000000:
if extension in ext and 'sample' not in filename and f_size > 50000000:
move_to = os.path.join(sortpath, filename)
os.rename(path, move_to)
pending = os.listdir(sortpath)

View File

@ -16,9 +16,10 @@ def move_to_sort(tv_downpath, sortpath, ext):
for dirpath, _, filenames in os.walk(tv_downpath):
for filename in filenames:
path = os.path.join(dirpath, filename)
_, extenstion = os.path.splitext(path)
_, extension = os.path.splitext(path)
extension = extension.lstrip('.').lower()
f_size = os.stat(path).st_size
if extenstion.lower() in ext and 'sample' not in filename and f_size > 50000000:
if extension in ext and 'sample' not in filename and f_size > 50000000:
move_to = os.path.join(sortpath, filename)
os.rename(path, move_to)
if os.listdir(sortpath):