Moved checks for sufficient info in order to move series or movie to the class. Homelocation in now a class function for each movie and series class.

This commit is contained in:
2018-09-23 16:29:41 +02:00
parent 379d789adc
commit a106a35d42
2 changed files with 27 additions and 21 deletions

View File

@@ -272,28 +272,11 @@ def scan_folder(path):
return videos
def movingToCollege(video, home_path):
video.home = titlecase(home_path)
def pickforgirlscouts(video):
if isinstance(video, Movie):
if video.title != None and video.year != None:
home_path = '{} ({})'.format(video.title, video.year)
try:
movingToCollege(video, home_path)
return True
except:
return False
elif isinstance(video, Episode):
if video.series != None and video.season != None and video.episode != None and type(video.episode) != list:
# Handle the list problems
home_path = '{} S{:02d}E{:02d}'.format(str(video.series), str(video.season), str(video.episode))
try:
movingToCollege(video, home_path)
return True
except:
return False
if video.sufficientInfo():
video.moveLocation()
print(video.home)
return True
return False

View File

@@ -7,6 +7,7 @@
from guessit import guessit
import os
from titlecase import titlecase
import hashlib, tvdb_api
#: Video extensions
@@ -165,6 +166,17 @@ class Episode(Video):
def fromname(cls, name):
return cls.fromguess(name, guessit(name, {'type': 'episode'}))
@classmethod
def sufficientInfo(self):
return None not in [self.series, self.season, self.episode] and list not in [type(self.series), type(self.episode)]
@classmethod
def moveLocation(self):
series = titlecase(self.series)
grandParent = '{}/{} {:02d}'.format(series, series, self.season)
parent = '{} S{:02d}E{:02d}'.format(series, self.season, self.episode)
self.home = os.path.join(grandParent, parent, self.name)
def __repr__(self):
if self.year is None:
return '<%s [%r, %dx%s]>' % (self.__class__.__name__, self.series, self.season, self.episode)
@@ -204,6 +216,17 @@ class Movie(Video):
def fromname(cls, name):
return cls.fromguess(name, guessit(name, {'type': 'movie'}))
@classmethod
def sufficientInfo(self):
return None not in [self.title, self.year]
@classmethod
def moveLocation(self):
title = titlecase(self.title)
parent = '{} ({})'.format(title, self.year)
self.home = os.path.join(parent, self.name)
def __repr__(self):
if self.year is None:
return '<%s [%r]>' % (self.__class__.__name__, self.title)