Merged to updated logger name.
This commit is contained in:
@@ -27,6 +27,10 @@ def listPath(path):
|
||||
else:
|
||||
print('Path does not exists')
|
||||
|
||||
def guessFromInput(video):
|
||||
print('Insufficient info for {}'.format(video.name))
|
||||
video_name = input('Input
|
||||
|
||||
@click.command()
|
||||
@click.argument('path')
|
||||
@click.option('--greeting', '-g')
|
||||
|
||||
10
src/core.py
10
src/core.py
@@ -25,7 +25,7 @@ from subtitle import SUBTITLE_EXTENSIONS, Subtitle, get_subtitle_path
|
||||
from utils import sanitize, refine
|
||||
|
||||
logging.basicConfig(filename=env.logfile, level=logging.DEBUG)
|
||||
logger = logging.getLogger('seasonedParser_core')
|
||||
logger = logging.getLogger('seasonedParser')
|
||||
fh = logging.FileHandler(env.logfile)
|
||||
fh.setLevel(logging.DEBUG)
|
||||
sh = logging.StreamHandler()
|
||||
@@ -70,6 +70,9 @@ def search_external_subtitles(path, directory=None):
|
||||
|
||||
return subtitles
|
||||
|
||||
def find_file_size(video):
|
||||
return os.path.getsize(video.name)
|
||||
|
||||
def scan_video(path):
|
||||
"""Scan a video from a `path`.
|
||||
|
||||
@@ -92,8 +95,8 @@ def scan_video(path):
|
||||
# guess
|
||||
video = Video.fromguess(path, guessit(path))
|
||||
|
||||
# size
|
||||
video.size = os.path.getsize(path)
|
||||
if video.sufficientInfo():
|
||||
video.setMoveLocation()
|
||||
|
||||
# hash of name
|
||||
# if isinstance(video, Movie):
|
||||
@@ -296,6 +299,7 @@ def scan_folder(path):
|
||||
v.subtitles |= set(search_external_subtitles(v.name))
|
||||
refine(v)
|
||||
videos.append(v)
|
||||
video.size = find_file_size()
|
||||
|
||||
click.echo('%s video%s collected / %s error%s' % (
|
||||
click.style(str(len(videos)), bold=True, fg='green' if videos else None),
|
||||
|
||||
24
src/video.py
24
src/video.py
@@ -13,7 +13,7 @@ import hashlib, tvdb_api
|
||||
|
||||
import env_variables as env
|
||||
|
||||
logger = logging.getLogger('seasonedParser_core')
|
||||
logger = logging.getLogger('seasonedParser')
|
||||
|
||||
#: Video extensions
|
||||
VIDEO_EXTENSIONS = ('.3g2', '.3gp', '.3gp2', '.3gpp', '.60d', '.ajp', '.asf', '.asx', '.avchd', '.avi', '.bik',
|
||||
@@ -33,13 +33,13 @@ class Video(object):
|
||||
:param str resolution: resolution of the video stream (480p, 720p, 1080p or 1080i, 4K).
|
||||
:param str video_codec: codec of the video stream.
|
||||
:param str audio_codec: codec of the main audio stream.
|
||||
:param str home: optimal parent folder.
|
||||
:param str move_location: location to move file to.
|
||||
:param dict name_hash: hashes of the video file by provider names.
|
||||
:param int size: size of the video file in bytes.
|
||||
:param set subtitles: existing subtitle languages.
|
||||
"""
|
||||
def __init__(self, name, hash=None, size=None, format=None, release_group=None, resolution=None, video_codec=None, audio_codec=None,
|
||||
home=None, subtitles=None, embeded_subtitles=None):
|
||||
move_location=None, subtitles=None, embeded_subtitles=None):
|
||||
#: Name or path of the video
|
||||
self.name = name
|
||||
|
||||
@@ -64,8 +64,8 @@ class Video(object):
|
||||
#: Codec of the main audio stream
|
||||
self.audio_codec = audio_codec
|
||||
|
||||
#: optimal home path; parent folder.
|
||||
self.home = home
|
||||
#: optimal move_location path; parent folder.
|
||||
self.move_location = move_location
|
||||
|
||||
#: Existing subtitle languages
|
||||
self.subtitles = subtitles or set()
|
||||
@@ -159,7 +159,7 @@ class Episode(Video):
|
||||
if guess['type'] != 'episode':
|
||||
raise ValueError('The guess must be an episode guess')
|
||||
|
||||
if 'title' not in guess or 'episode' not in guess:
|
||||
if 'title' not in guess or 'season' not in guess or 'episode' not in guess:
|
||||
raise ValueError('Insufficient data to process the guess')
|
||||
|
||||
return cls(name, guess['title'], guess.get('season', 1), guess['episode'], title=guess.get('episode_title'),
|
||||
@@ -186,11 +186,11 @@ class Episode(Video):
|
||||
|
||||
return True
|
||||
|
||||
def moveLocation(self):
|
||||
def setMoveLocation(self):
|
||||
series = titlecase(self.series)
|
||||
grandParent = '{}/{} Season {:02d}'.format(series, series, self.season)
|
||||
parent = '{} S{:02d}E{:02d}'.format(series, self.season, self.episode)
|
||||
self.home = os.path.join(env.SHOWBASE, grandParent, parent, os.path.basename(self.name))
|
||||
self.move_location = os.path.join(env.SHOWBASE, grandParent, parent, os.path.basename(self.name))
|
||||
|
||||
def __repr__(self):
|
||||
if self.year is None:
|
||||
@@ -220,7 +220,7 @@ class Movie(Video):
|
||||
if guess['type'] != 'movie':
|
||||
raise ValueError('The guess must be a movie guess')
|
||||
|
||||
if 'title' not in guess:
|
||||
if 'title' not in guess or 'year' not in guess:
|
||||
raise ValueError('Insufficient data to process the guess')
|
||||
|
||||
return cls(name, guess['title'], format=guess.get('format'), release_group=guess.get('release_group'),
|
||||
@@ -228,7 +228,7 @@ class Movie(Video):
|
||||
audio_codec=guess.get('audio_codec'), year=guess.get('year'))
|
||||
|
||||
@classmethod
|
||||
def fromname(cls, name):
|
||||
def fromname(cls, name, year):
|
||||
return cls.fromguess(name, guessit(name, {'type': 'movie'}))
|
||||
|
||||
def sufficientInfo(self):
|
||||
@@ -244,10 +244,10 @@ class Movie(Video):
|
||||
|
||||
return True
|
||||
|
||||
def moveLocation(self):
|
||||
def setMoveLocation(self):
|
||||
title = titlecase(self.title)
|
||||
parent = '{} ({})'.format(title, self.year)
|
||||
self.home = os.path.join(env.MOVIEBASE, parent, os.path.basename(self.name))
|
||||
self.move_location = os.path.join(env.MOVIEBASE, parent, os.path.basename(self.name))
|
||||
|
||||
def __repr__(self):
|
||||
if self.year is None:
|
||||
|
||||
Reference in New Issue
Block a user