Пример #1
0
 def test_setting_the_position_of_a_shows_leading_the_to_the_end_of_the_file_name(self):
     fn = 'The.Big.Bang.Theory.S03E01.HDTV.XviD-NoTV.avi'
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name, the=True)
     path = self.tv.build_path(episode, organise=False)
     self.tv.rename(fn, path)
     assert_true(isfile(join(self.files, 'Big Bang Theory, The - 301 - The Electric Can Opener Fluctuation.avi')))
Пример #2
0
 def test_setting_an_episodes_format_as_title_episode_season_name(self):
     fn = 'chuck.s1e08.blah.HDTV.XViD.avi'
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name)
     assert_equal(self.tv.build_path(
         episode, rename_dir=self.files, organise=False, format='%t - %e - %s - %n%x'),
         join(self.files, 'Chuck Versus the Truth - 08 - 1 - Chuck.avi'))
Пример #3
0
 def test_episode_already_exists_raise_exception(self):
     with open(join(self.files, 'Chuck - 205 - Chuck Versus Tom Sawyer.avi'), 'w'):
         pass
     fn = 'chuck.s02e05.avi'
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.title = self.tv.retrieve_episode_name(episode)
     path = self.tv.build_path(episode, organise=False)
     assert_raises(EpisodeAlreadyExistsInDirectoryException, self.tv.rename, fn, path)
Пример #4
0
 def test_using_organise_renames_the_file_correctly(self):
     fn = "chuck.s1e06.foo.HD.avi"
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name)
     path = self.tv.build_path(episode, organise=self.organise, rename_dir=self.organised)
     self.tv.rename(fn, path)
     assert_true(isfile(join(self.organised + "/Chuck/Season 1", "Chuck - 106 - Chuck Versus the Sandworm.avi")))
Пример #5
0
 def test_passing_in_an_episode_number_returns_the_correct_episode_title(self):
     fn = 'chuck.s1e08.blah.HDTV.XViD.avi'
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.episode = '9'
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name)
     path = self.tv.build_path(episode, organise=False)
     self.tv.rename(fn, path)
     assert_true(isfile(join(self.files, 'Chuck - 109 - Chuck Versus the Imported Hard Salami.avi')))
Пример #6
0
 def test_passing_in_a_season_number_renames_a_file_using_that_season_number(self):
     fn = 'chuck.s1e08.blah.HDTV.XViD.avi'
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.season = 2
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name)
     path = self.tv.build_path(episode, organise=False)
     self.tv.rename(fn, path)
     assert_true(isfile(join(self.files, 'Chuck - 208 - Chuck Versus the Gravitron.avi')))
Пример #7
0
 def test_passing_in_a_show_name_renames_a_file_using_that_name(self):
     fn = 'doctor.who.s5e10.blah.HDTV.XViD.avi'
     final_fn = 'Doctor Who (2005) - 510 - Vincent and the Doctor.avi'
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.show_name = 'Doctor Who (2005)'
     episode.title = self.tv.retrieve_episode_name(episode)
     path = self.tv.build_path(episode, organise=False)
     self.tv.rename(fn, path)
     assert_true(isfile(join(self.files, final_fn)))
Пример #8
0
 def test_rename_with_tvdb_falling_over(self):
     fn = 'chuck.s1e08.blah.HDTV.XViD.avi'
     final_fn = 'Chuck - 108 - Chuck Versus the Truth.avi'
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name)
     path = self.tv.build_path(episode, organise=False)
     self.tv.rename(fn, path)
     assert_true(exists(join(self.files, final_fn)))
Пример #9
0
 def test_moving_the_leading_the_to_the_end_of_a_show_name_causes_the_show_folder_name_to_follow_suit_when_using_organise(
     self
 ):
     fn = "The.Big.Bang.Theory.S03E01.HDTV.XviD-NoTV.avi"
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name, the=True)
     path = self.tv.build_path(episode, organise=self.organise, rename_dir=self.organised)
     self.tv.rename(fn, path)
     assert_true(isdir(join(self.organised, "Big Bang Theory, The/Season 3")))
Пример #10
0
 def test_passing_in_a_series_name_renames_a_file_using_that_name(self):
     fn = 'avatar.s1e08.blah.HDTV.XViD.avi'
     episode = Episode(self.tv.extract_details_from_file(fn,
                       user_regex='%n.s%s{1}e%e{2}.blah'))
     episode.show_name = 'Avatar: The Last Airbender'
     episode.title = 'Winter Solstice (2): Avatar Roku'
     path = self.tv.build_path(episode, organise=False)
     self.tv.rename(fn, path)
     assert_true(isfile(join(self.files,
                 'Avatar, The Last Airbender - 108 - Winter Solstice (2), Avatar Roku.avi')))
Пример #11
0
 def test_using_organise_moves_the_file_to_the_correct_folder(self):
     fn = "stargate.sg-1.s10e18.xvid.avi"
     episode = Episode(self.tv.extract_details_from_file(fn))
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name)
     path = self.tv.build_path(episode, organise=self.organise, rename_dir=self.organised)
     self.tv.rename(fn, path)
     for fn in listdir(self.organised):
         if fn == "Stargate SG-1":
             full_path = fn
             for other in listdir(join(self.organised, fn)):
                 if other == "Season 10":
                     full_path = full_path + "/" + other + "/"
                     for fn in listdir(join(self.organised, full_path)):
                         full_path = full_path + fn
     assert_equal(full_path, "Stargate SG-1/Season 10/Stargate SG-1 - 1018 - Family Ties.avi")
Пример #12
0
def worker(queue, working_dir, config_path):
    log = logging.getLogger('tvrd.worker')
    while True:
        item = queue.get()  # should be file or folder
        if os.path.isfile(item):
            item = os.path.split(item)[1]
        log.debug('Found: {0}'.format(item))
        try:
            tv = TvRenamr(working_dir, Config(config_path))
            episode = Episode(**tv.extract_details_from_file(item))
            episode.title = tv.retrieve_episode_name(episode)
            episode.show_name = tv.format_show_name(episode.show_name)
            destination = tv.rename(item, tv.build_path(episode))

            remove_torrent(item)

            log.log(21, os.path.splitext(os.path.split(destination)[1])[0])
        except Exception as e:
            for msg in e.args:
                kwargs = {'type': e.__repr__()[:e.__repr__().index('(')], 'error': msg}
                log.critical('{type}: {error}'.format(**kwargs))
            continue
        time.sleep(1)  # don't use 100% cpu
        queue.task_done()
Пример #13
0
 def test_passing_in_an_episode_number_renames_a_file_using_that_episode_number(self):
     episode = Episode(self.tv.extract_details_from_file('chuck.s1e08.blah.HDTV.XViD.avi'))
     episode.episode = 9
     assert_equal(self.tv.retrieve_episode_name(episode), 'Chuck Versus the Imported Hard Salami')
Пример #14
0
 def test_passing_in_a_season_number_to_retrieve_episode_name_returns_the_correct_episode_name_from_that_season(self):
     episode = Episode(self.tv.extract_details_from_file('chuck.s1e08.avi'))
     episode.season = 2
     assert_equal(self.tv.retrieve_episode_name(episode), 'Chuck Versus the Gravitron')
Пример #15
0
 def test_using_organise_returns_the_correct_path_based_on_the_episode(self):
     episode = Episode(self.tv.extract_details_from_file("true.blood.0205.avi"))
     episode.title = self.tv.retrieve_episode_name(episode)
     episode.show_name = self.tv.format_show_name(episode.show_name, the=False)
     path = self.tv.build_path(episode, organise=self.organise, rename_dir=self.organised)
     assert_equal(path, join(self.organised, "True Blood/Season 2/True Blood - 205 - Never Let Me Go.avi"))