mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Flatten process_dir
This commit is contained in:
parent
8d458f10ac
commit
cb422a0cea
1 changed files with 57 additions and 53 deletions
|
@ -4,7 +4,7 @@ from __future__ import print_function, unicode_literals
|
|||
|
||||
import os
|
||||
|
||||
import beets
|
||||
import beets.mediafile
|
||||
import guessit
|
||||
import requests
|
||||
from six import text_type
|
||||
|
@ -79,19 +79,7 @@ def clean_dir(path, section, subsection):
|
|||
return clean_directory(path, files)
|
||||
|
||||
|
||||
def process_dir(path, link):
|
||||
folders = []
|
||||
|
||||
logger.info('Searching {0} for mediafiles to post-process ...'.format(path))
|
||||
sync = [o for o in os.listdir(text_type(path)) if os.path.splitext(o)[1] in ['.!sync', '.bts']]
|
||||
# search for single files and move them into their own folder for post-processing
|
||||
for mediafile in [os.path.join(path, o) for o in os.listdir(text_type(path)) if
|
||||
os.path.isfile(os.path.join(path, o))]:
|
||||
if len(sync) > 0:
|
||||
break
|
||||
if os.path.split(mediafile)[1] in ['Thumbs.db', 'thumbs.db']:
|
||||
continue
|
||||
try:
|
||||
def move_file(mediafile, path, link):
|
||||
logger.debug('Found file {0} in root directory {1}.'.format(os.path.split(mediafile)[1], path))
|
||||
new_path = None
|
||||
file_ext = os.path.splitext(mediafile)[1]
|
||||
|
@ -144,6 +132,22 @@ def process_dir(path, link):
|
|||
|
||||
# link file to its new path
|
||||
copy_link(mediafile, newfile, link)
|
||||
|
||||
|
||||
def process_dir(path, link):
|
||||
folders = []
|
||||
|
||||
logger.info('Searching {0} for mediafiles to post-process ...'.format(path))
|
||||
sync = [o for o in os.listdir(text_type(path)) if os.path.splitext(o)[1] in ['.!sync', '.bts']]
|
||||
# search for single files and move them into their own folder for post-processing
|
||||
for mediafile in [os.path.join(path, o) for o in os.listdir(text_type(path)) if
|
||||
os.path.isfile(os.path.join(path, o))]:
|
||||
if len(sync) > 0:
|
||||
break
|
||||
if os.path.split(mediafile)[1] in ['Thumbs.db', 'thumbs.db']:
|
||||
continue
|
||||
try:
|
||||
move_file(mediafile, path, link)
|
||||
except Exception as e:
|
||||
logger.error('Failed to move {0} to its own directory: {1}'.format(os.path.split(mediafile)[1], e))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue