def verify_name_gen(curtest, tvdb_instance): if "seasonnumber" in curtest: ep = EpisodeInfo( filename = curtest['input'], eptype = 'default', seriesname = curtest['parsedseriesname'], seasonnumber = curtest['seasonnumber'], episodenumbers = curtest['episodenumbers']) elif any([isinstance(x, datetime.date) for x in curtest['episodenumbers']]): ep = EpisodeInfo( filename = curtest['input'], eptype = 'dated', seriesname = curtest['parsedseriesname'], episodenumbers = curtest['episodenumbers']) else: ep = EpisodeInfo( filename = curtest['input'], eptype = 'noseason', seriesname = curtest['parsedseriesname'], episodenumbers = curtest['episodenumbers']) ep.populateFromTvdb(tvdb_instance, force_name = curtest.get("force_name")) assert ep.seriesname is not None, "Corrected series name was none" assert ep.episodename is not None, "Episode name was None" assertEquals(ep.seriesname, curtest['correctedseriesname']) assertEquals(ep.episodename, curtest['episodenames'])
def test_no_name(): """Episode without a name """ ep = EpisodeInfo( seriesname="Scrubs", seasonnumber=1, episodenumbers=[2], episodename=None, filename="scrubs.example.file.avi" ) assertEquals(ep.generateFilename(), "Scrubs - [01x02].avi")
def test_simple_no_ext(self): """Simple episode with out extension """ ep = EpisodeInfo( seriesname="Scrubs", seasonnumber=1, episodenumbers=[2], episodename="My Mentor", filename=None ) self.assertEquals(ep.generateFilename(), "Scrubs - [01x02] - My Mentor")
def test_no_series_number(self): """Episode without series number """ ep = EpisodeInfo( seriesname="Scrubs", seasonnumber=None, episodenumbers=[2], episodename="My Mentor", filename=None ) self.assertEquals(ep.generateFilename(), "Scrubs - [02] - My Mentor")
def get_episode_description(episode): populateFromTvdb(episode) ep = EpisodeInfo( seriesname = episode.seriesname, seasonnumber = episode.seasonnumber, episodenumbers = episode.episodenumbers, episodename = episode.episodename, filename = None) return ep.generateFilename()
def test_multi_episodes_continuous(self): ep = EpisodeInfo( seriesname="Stargate SG-1", seasonnumber=1, episodenumbers=[1, 2], episodename=["Children of the Gods (1)", "Children of the Gods (2)"], filename="stargate.example.file.avi", ) self.assertEquals(ep.generateFilename(), "Stargate SG-1 - [01x01-02] - Children of the Gods (1-2).avi")
def test_multi_episodes_continuous(): """A two-part episode should not have the episode name repeated """ ep = EpisodeInfo( seriesname="Stargate SG-1", seasonnumber=1, episodenumbers=[1, 2], episodename=["Children of the Gods (1)", "Children of the Gods (2)"], filename="stargate.example.file.avi", ) assertEquals(ep.generateFilename(), "Stargate SG-1 - [01x01-02] - Children of the Gods (1-2).avi")
def test_multi_episodes_seperate(): """File with two episodes, but with different names """ ep = EpisodeInfo( seriesname="Stargate SG-1", seasonnumber=1, episodenumbers=[2, 3], episodename=["Children of the Gods (2)", "The Enemy Within"], filename="stargate.example.file.avi", ) assertEquals(ep.generateFilename(), "Stargate SG-1 - [01x02-03] - Children of the Gods (2), The Enemy Within.avi")
def test_downcase(): """Simple episode name, converted to lowercase """ ep = EpisodeInfo( seriesname="Scrubs", seasonnumber=1, episodenumbers=[2], episodename="My Mentor", filename="scrubs.example.file.avi", ) assertEquals(ep.generateFilename(lowercase=True), "scrubs - [01x02] - my mentor.avi")
def test_datedepisode_no_name_no_ext(): """Dated EpisodeInfo with no name or extension """ ep = EpisodeInfo( seriesname = 'Scrubs', eptype = 'dated', episodenumbers = [datetime.date(2010, 11, 23)], episodename = '', filename = '') assertEquals( ep.generateFilename(), 'Scrubs - [2010-11-23]')
def test_noseason_no_name_no_ext(): """NoSeason EpisodeInfo with no name or extension """ ep = EpisodeInfo( seriesname = 'Scrubs', eptype = 'noseason', episodenumbers = [2], episodename = '', filename = '') assertEquals( ep.generateFilename(), 'Scrubs - [02]')
def test_episode_numeric_title(): """An episode with a name starting with a number should not be detected as a range """ ep = EpisodeInfo(seriesname='Star Trek TNG', seasonnumber=1, episodenumbers=[15], episodename=['11001001'], filename='STTNG-S01E15-11001001.avi') assertEquals(ep.generateFilename(), 'Star Trek TNG - [01x15] - 11001001.avi')
def test_multi_episodes_continuous(): """A two-part episode should not have the episode name repeated """ ep = EpisodeInfo( seriesname='Stargate SG-1', seasonnumber=1, episodenumbers=[1, 2], episodename=['Children of the Gods (1)', 'Children of the Gods (2)'], filename='stargate.example.file.avi') assertEquals( ep.generateFilename(), 'Stargate SG-1 - [01x01-02] - Children of the Gods (1-2).avi')
def test_single_episode(): """Simple episode name, with show/season/episode/name/filename """ ep = EpisodeInfo( seriesname="Scrubs", seasonnumber=1, episodenumbers=[2], episodename="My Mentor", filename="scrubs.example.file.avi", ) assertEquals(ep.generateFilename(), "Scrubs - [01x02] - My Mentor.avi")
def test_episode_no_name_no_ext(): """EpisodeInfo with no name or extension """ ep = EpisodeInfo( seriesname = 'Scrubs', seasonnumber = 1, episodenumbers = [2], episodename = None, filename = None) assertEquals( ep.generateFilename(), 'Scrubs - [01x02]')
def test_multi_episodes_seperate(): ep = EpisodeInfo( seriesname = 'Stargate SG-1', seasonnumber = 1, episodenumbers = [2, 3], episodename = [ 'Children of the Gods (2)', 'The Enemy Within'], filename = 'stargate.example.file.avi') assertEquals( ep.generateFilename(), 'Stargate SG-1 - [01x02-03] - Children of the Gods (2), The Enemy Within.avi')
def test_simple_no_ext(): """Simple episode with out extension """ ep = EpisodeInfo( seriesname = 'Scrubs', seasonnumber = 1, episodenumbers = [2], episodename = 'My Mentor', filename = None) assertEquals( ep.generateFilename(), 'Scrubs - [01x02] - My Mentor')
def test_no_series_number(): """Episode without series number """ ep = EpisodeInfo( seriesname = 'Scrubs', seasonnumber = None, episodenumbers = [2], episodename = 'My Mentor', filename = None) assertEquals( ep.generateFilename(), 'Scrubs - [02] - My Mentor')
def test_multi_episodes_continuous(): ep = EpisodeInfo( seriesname = 'Stargate SG-1', seasonnumber = 1, episodenumbers = [1, 2], episodename = [ 'Children of the Gods (1)', 'Children of the Gods (2)'], filename = 'stargate.example.file.avi') assertEquals( ep.generateFilename(), 'Stargate SG-1 - [01x01-02] - Children of the Gods (1-2).avi')
def test_multi_episodes_seperate(): """File with two episodes, but with different names """ ep = EpisodeInfo( seriesname='Stargate SG-1', seasonnumber=1, episodenumbers=[2, 3], episodename=['Children of the Gods (2)', 'The Enemy Within'], filename='stargate.example.file.avi') assertEquals( ep.generateFilename(), 'Stargate SG-1 - [01x02-03] - Children of the Gods (2), The Enemy Within.avi' )
def test_single_episode(): """Simple episode name, with show/season/episode/name/filename """ ep = EpisodeInfo( seriesname = 'Scrubs', seasonnumber = 1, episodenumbers = [2], episodename = 'My Mentor', filename = 'scrubs.example.file.avi') assertEquals( ep.generateFilename(), 'Scrubs - [01x02] - My Mentor.avi')
def test_downcase(): """Simple episode name, converted to lowercase """ ep = EpisodeInfo( seriesname = 'Scrubs', seasonnumber = 1, episodenumbers = [2], episodename = 'My Mentor', filename = 'scrubs.example.file.avi') assertEquals( ep.generateFilename(lowercase = True), 'scrubs - [01x02] - my mentor.avi')
def test_episode_numeric_title(): """An episode with a name starting with a number should not be detected as a range """ ep = EpisodeInfo( seriesname="Star Trek TNG", seasonnumber=1, episodenumbers=[15], episodename=["11001001"], filename="STTNG-S01E15-11001001.avi", ) assertEquals(ep.generateFilename(), "Star Trek TNG - [01x15] - 11001001.avi")
def get_episode_description(episode): populateFromTvdb(episode) ep = EpisodeInfo( seriesname = episode.seriesname, seasonnumber = episode.seasonnumber, episodenumbers = episode.episodenumbers, episodename = episode.episodename, filename = None) return ep
def verify_name_gen(curtest, tvdb_instance): if "seasonnumber" in curtest: ep = EpisodeInfo( seriesname=curtest["parsedseriesname"], seasonnumber=curtest["seasonnumber"], episodenumbers=curtest["episodenumbers"], ) elif any([isinstance(x, datetime.date) for x in curtest["episodenumbers"]]): ep = DatedEpisodeInfo(seriesname=curtest["parsedseriesname"], episodenumbers=curtest["episodenumbers"]) else: ep = NoSeasonEpisodeInfo(seriesname=curtest["parsedseriesname"], episodenumbers=curtest["episodenumbers"]) ep.populateFromTvdb(tvdb_instance, force_name=curtest.get("force_name")) assert ep.seriesname is not None, "Corrected series name was none" assert ep.episodename is not None, "Episode name was None" assertEquals(ep.seriesname, curtest["correctedseriesname"]) assertEquals(ep.episodename, curtest["episodenames"])
def verify_name_gen(curtest, tvdb_instance): if "seasonnumber" in curtest: ep = EpisodeInfo(seriesname=curtest['parsedseriesname'], seasonnumber=curtest['seasonnumber'], episodenumbers=curtest['episodenumbers']) elif any([isinstance(x, datetime.date) for x in curtest['episodenumbers']]): ep = DatedEpisodeInfo(seriesname=curtest['parsedseriesname'], episodenumbers=curtest['episodenumbers']) else: ep = NoSeasonEpisodeInfo(seriesname=curtest['parsedseriesname'], episodenumbers=curtest['episodenumbers']) ep.populateFromTvdb(tvdb_instance) assert ep.seriesname is not None, "Corrected series name was none" assert ep.episodename is not None, "Episode name was None" assertEquals(ep.seriesname, curtest['correctedseriesname']) assertEquals(ep.episodename, curtest['episodenames'])
def test_no_name_no_ext(self): """Episode with no name or extension """ ep = EpisodeInfo(seriesname="Scrubs", seasonnumber=1, episodenumbers=[2], episodename=None, filename=None) self.assertEquals(ep.generateFilename(), "Scrubs - [01x02]")