def _prepare_synthetic_episodes(self): self.episodes = [] count = 0 for t in self.episode_titles: e = Episode(self.sub) e.guid = count e.title = t e.url = 'http://www.example.com/foo/bar/baz.mp3' count = count + 1 self.episodes.append(e)
def parse_rss_file(self, filename): episodes = [] root = self._fetch_root(filename) self.title = (root.findall("./channel/title")[0].text) elements = root.findall("./channel/item") for el in elements: episode = Episode(self) self.pubdate_to_timestamp(el.findall('pubDate')[0].text, episode) episode.title = el.findall('title')[0].text episode.guid = el.findall('guid')[0].text episode.description = el.findall('description')[0].text e = el.findall('enclosure') if e and len(e) > 0: episode.url = e[0].get('url') episode.enclosure_length = e[0].get('length') if episode.pubDate and episode.url and episode.title \ and episode.guid: episodes.append(episode) return episodes
def rename(self, details): working, filename = details try: tv = TvRenamr(working, self.config, options.debug, options.dry) episode = Episode(tv.extract_details_from_file(filename, user_regex=options.regex)) if options.show: episode.show_name = options.show if options.season: episode.season = options.season if options.episode: episode.episode = options.episode episode.title = tv.retrieve_episode_name(episode, library=options.library, canonical=options.canonical) episode.show_name = tv.format_show_name(episode.show_name, the=options.the, override=options.show_override) path = tv.build_path( episode, rename_dir=options.rename_dir, organise=options.organise, format=options.output_format ) tv.rename(filename, path) except (ConfigNotFoundException, NoMoreLibrariesException, NoNetworkConnectionException): if options.dry or options.debug: self._stop_dry_run() sys.exit(1) except ( EmptyEpisodeNameException, EpisodeAlreadyExistsInDirectoryException, EpisodeNotFoundException, IncorrectCustomRegularExpressionSyntaxException, InvalidXMLException, OutputFormatMissingSyntaxException, ShowNotFoundException, UnexpectedFormatException, ): pass except Exception as err: if options.debug: # In debug mode, show the full traceback. raise log.critical("tvr: critical error: %s" % str(err)) sys.exit(1)