def renameDirectory(self, service, new_name): try: dir_name = os.path.dirname(self.service.getPath()[0:-1]) os.rename(self.service.getPath(), os.path.join(dir_name, self.input_file.getText() + "/")) self.original_file = self.input_file.getText() except: printStackTrace()
def run(self): try: self.cancel = False global current, total, movie_title total = len(self.items) current = 0 for item_list in self.items: try: if self.cancel: #print "Movie download cancelled" self.finish() return service = item_list[0] if not isinstance(service, eServiceReference): service = service.serviceref if service.flags & eServiceReference.mustDescent: total = total - 1 continue current = current + 1 movie_title = ServiceCenter.getInstance().info(service).getName(service).encode("utf-8").split(" - ")[0].strip() createEIT(service.getPath(), movie_title, self.coversize) except: printStackTrace() except: printStackTrace() finally: self.finish()
def run(self): try: self.cancel = False self.total = len(self.items) self.current = 0 for item_list in self.items: try: if self.cancel: #print "Movie download cancelled" return service = item_list[0] if not isinstance(service, eServiceReference): service = service.serviceref if service.flags & eServiceReference.mustDescent: self.total -= 1 continue self.current += 1 print service.toString() name = ServiceCenter.getInstance().info(service).getName(service) self.movie_title = name eitFromTMDb(service.getPath(), self.movie_title) except: printStackTrace() except: printStackTrace() finally: self.current = self.total self.finished = True
def run(self): try: self.cancel = False global current, total, movie_title total = len(self.items) current = 0 for item_list in self.items: try: if self.cancel: #print "Movie download cancelled" self.finish() return service = item_list[0] if not isinstance(service, eServiceReference): service = service.serviceref if service.flags & eServiceReference.mustDescent: total = total - 1 continue current = current + 1 movie_title = ServiceCenter.getInstance().info(service).getName(service).encode("utf-8").split(" - ")[0].strip() createEIT(service.getPath(), movie_title) except: printStackTrace() except: printStackTrace() finally: self.finish()
def showEpisodeList(self, movie): searchTitle = self.searchTitle self.setTitle(_("Episodes for: %s") % (self.getInfoText())) results = tvdb.search(searchTitle) tmpEpisodeList = [] episodeIndex = -1 if len(results) > 0: try: for episode in movie['Episode']: episode_name = "" name = episode['EpisodeName'] if name: episode_name = name.encode('utf-8', 'ignore') episode_number = episode['EpisodeNumber'] if episode_number: episode_number = episode_number.encode( 'utf-8', 'ignore') season_number = episode['SeasonNumber'] if season_number: episode_season_number = season_number.encode( 'utf-8', 'ignore') id_txt = episode['id'] if id_txt: episode_id = id_txt.encode('utf-8', 'ignore') episode_overview = "" overview = episode['Overview'] if overview: episode_overview = overview.encode('utf-8', 'ignore') else: episode_overview = (_( "Sorry, no description for this episode at TheTVDB.com available!" )) if episode_name != "" and self.description != "": if episode_name == self.description: episodeIndex = len(tmpEpisodeList) tmpEpisodeList.append( (episode, episode_name, episode_number, episode_season_number, episode_id, episode_overview), ) except: printStackTrace() if len(tmpEpisodeList) > 0: self.updateView(self.SHOW_EPISODE_LIST) self["episodes_list"].setList(tmpEpisodeList) self["episodes_list"].moveSelectionTo(episodeIndex) if len(tmpEpisodeList) == 1: txt = (_("Total %s") % len(tmpEpisodeList) + ' ' + _("episode found")) else: txt = (_("Total %s") % len(tmpEpisodeList) + ' ' + _("episodes found")) self["result_txt"].setText(txt) else: self.updateView(self.SHOW_EPISODE_NO_RESULT)
def renameFile(self, service, new_name): try: path = os.path.dirname(service.getPath()) file_name = os.path.basename(os.path.splitext(service.getPath())[0]) src = os.path.join(path, file_name) dst = os.path.join(path, new_name) import glob for f in glob.glob(os.path.join(path, src + "*")): os.rename(f, f.replace(src, dst)) except: printStackTrace()
def buildMovieSelectionListEntry(self, movie, movie_base=None): width = self.l.getItemSize().width() height = self.l.getItemSize().height() res = [None] try: for callback in self.build_update_callback: callback(movie) name = movie.Title if movie_base: name = movie_base + " - " + movie.Title if isinstance(movie.ReleaseDate, datetime.date): released = str(movie.ReleaseDate.year) else: released = str(movie.ReleaseDate) cover_url = movie.poster_url if not cover_url: png = self.picloader.load(getNocover()) else: parts = cover_url.split("/") filename = os_path.join(IMAGE_TEMPFILE, str(movie.ID) + str(parts[-1])) print filename if downloadCover(cover_url, filename): png = self.picloader.load(filename) else: png = self.picloader.load(getNocover()) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, self.picPos.x(), self.picPos.y(), self.picSize.width(), self.picSize.height(), png)) res.append( (eListboxPythonMultiContent.TYPE_TEXT, self.line1Pos.x(), self.line1Pos.y(), width - self.line1Pos.x(), self.f0h, 0, RT_HALIGN_LEFT, name)) res.append((eListboxPythonMultiContent.TYPE_TEXT, width - 255, self.line1Pos.y(), 250, self.f0h, 0, RT_HALIGN_RIGHT, released)) res.append( (eListboxPythonMultiContent.TYPE_TEXT, self.line2Pos.x(), self.line2Pos.y(), width - self.line2Pos.x(), height - self.line2Pos.y(), 1, RT_WRAP, movie.Overview)) except: from Source.Globals import printStackTrace printStackTrace() return res
def searchForMovies(self): try: title = self.searchTitle results = self.tmdb3.searchMovie(title) if len(results) == 0 and ' - ' in self.searchTitle: title = self.searchTitle.split(' - ')[0].strip() results = self.tmdb3.searchMovie(title) if len(results) > 0: self.searchTitle = title if len(results) == 0 and ' & ' in self.searchTitle: title = self.searchTitle.split(' & ')[0].strip() results = self.tmdb3.searchMovie(title) if len(results) > 0: self.searchTitle = title if len(results) == 0 and self.searchTitle.endswith('.ts'): title = self.searchTitle[:-3] results = self.tmdb3.searchMovie(title) if len(results) > 0: self.searchTitle = title print('[SerchTMDB]', title, str(len(results))) if len(results) == 0: self.updateView(self.SHOW_SEARCH_NO_RESULT) self['status'].setText( _("No data found for ' %s ' at themoviedb.org!") % self.searchTitle) self.session.openWithCallback( self.askForSearchCallback, MessageBox, _("No data found for ' %s ' at themoviedb.org!\nDo you want to edit the search name?" ) % self.searchTitle) return self.movies = [] for movie in results: if movie is not None: self.movies.append((movie, )) self['list'].setList(self.movies) self.showMovieList() except Exception as e: from Source.Globals import printStackTrace printStackTrace() self['status'].setText(_('Error!\n%s' % e)) self['status'].show() return return
def renameVDir(self, dir_name, name): try: if not dir_name + "\t" + self.original_name in self.movieConfig.rename: self.movieConfig.rename.append(dir_name + "\t" + name) elif name == "": for index, item in enumerate(self.movieConfig.rename): i = item.split("\t") if i[0] == dir_name: print dir_name + "\t" + name del self.movieConfig.rename[index] else: for index, item in enumerate(self.movieConfig.rename): i = item.split("\t") if i[0] == dir_name: self.movieConfig.rename[index] = dir_name + "\t" + name self.movieConfig.safe() except: printStackTrace()
def buildMovieSelectionListEntry(self, movie): width = self.l.getItemSize().width() res = [None] try: name = movie.title overview = movie.overview released = None if isinstance(movie.releasedate, datetime.datetime): released = movie.releasedate.year cover_url = movie.poster_url if overview: overview = overview.encode('utf-8', 'ignore') else: overview = '' if released: released_text = released else: released_text = '' if not cover_url: png = self.picloader.load(nocover) else: parts = cover_url.split('/') filename = os_path.join(IMAGE_TEMPFILE, str(movie.id) + str(parts[(-1)])) print(filename) if downloadCover(cover_url, filename): png = self.picloader.load(filename) else: png = self.picloader.load(nocover) res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 1, 92, 138, png)) res.append((eListboxPythonMultiContent.TYPE_TEXT, 100, 5, width - 100, 20, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, '%s' % name.encode('utf-8', 'ignore'))) res.append( (eListboxPythonMultiContent.TYPE_TEXT, width - 140, 5, 130, 20, 1, RT_HALIGN_RIGHT | RT_VALIGN_CENTER, '%s' % released_text)) res.append((eListboxPythonMultiContent.TYPE_TEXT, 100, 30, width - 100, 100, 1, RT_WRAP, '%s' % overview)) except: from Source.Globals import printStackTrace printStackTrace() return res
def searchForMovies(self): try: title = self.searchTitle results = tmdb.searchMovie(title) print "[SerchTMDB]", title, str(len(results)) if len(results) == 0: self.showNoSearchResult() return self.movies = [] for movie in results: if movie is not None: self.movies.append((movie, ), ) self["list"].setList(self.movies) self.showMovieList() except Exception, e: from Source.Globals import printStackTrace printStackTrace() self["status"].setText(_("Error!\n%s" % e)) self["status"].show() return
def saveTags(self, file, tags): try: meta_file = file + ".ts.meta" print "saveTags", meta_file if os_path.exists(meta_file): metafile = open(meta_file, "r") sid = metafile.readline().strip("\r\n") title = metafile.readline().strip("\r\n") descr = metafile.readline().strip("\r\n") time = metafile.readline().strip("\r\n") oldtags = metafile.readline().rstrip("\r\n") rest = metafile.read() metafile.close() tags = " ".join(tags) if tags != oldtags: metafile = open(meta_file, "w") metafile.write("%s\n%s\n%s\n%s\n%s\n%s" % (sid, title, descr, time, tags, rest)) metafile.close() except: from Source.Globals import printStackTrace printStackTrace()
def saveTags(self, file, tags): try: meta_file = file + ".ts.meta" print("saveTags", meta_file) if os_path.exists(meta_file): metafile = open(meta_file, "r") sid = metafile.readline().strip("\r\n") title = metafile.readline().strip("\r\n") descr = metafile.readline().strip("\r\n") time = metafile.readline().strip("\r\n") oldtags = metafile.readline().rstrip("\r\n") rest = metafile.read() metafile.close() tags = " ".join(tags) if tags != oldtags: metafile = open(meta_file, "w") metafile.write("%s\n%s\n%s\n%s\n%s\n%s" % (sid, title, descr, time, tags, rest)) metafile.close() except: from Source.Globals import printStackTrace printStackTrace()
def setTitleDescr(self, service, title, descr): try: if service.getPath().endswith(".ts"): meta_file = service.getPath() + ".meta" else: meta_file = service.getPath() + ".ts.meta" # Create new meta for ts files if not os.path.exists(meta_file): if os.path.isfile(service.getPath()): _title = os.path.basename( os.path.splitext(service.getPath())[0]) else: _title = service.getName() _sid = "0:0:0:0:0:0:0:0:0:0:" _descr = "" _time = "" _tags = "" metafile = open(meta_file, "w") metafile.write("%s\n%s\n%s\n%s\n%s" % (_sid, _title, _descr, _time, _tags)) metafile.close() if os.path.exists(meta_file): metafile = open(meta_file, "r") sid = metafile.readline() oldtitle = metafile.readline().rstrip() olddescr = metafile.readline().rstrip() rest = metafile.read() metafile.close() if not title and title != "": title = oldtitle if not descr and descr != "": descr = olddescr metafile = open(meta_file, "w") metafile.write("%s%s\n%s\n%s" % (sid, title, descr, rest)) metafile.close() except: printStackTrace()
def searchForMovies(self): try: results = TMDbSeriesInfo.search(self.searchTitle) if len(results) == 0: self.showNoSearchResult() return update_seasons = len(results) == 1 update_episode = len(results) == 1 and self.description self.movies = [] found = (None, -1) for serie in results: if update_seasons: serie.update() self.movies.append((serie, ), ) for season in serie.seasons: #self.movies.append((season, str(season.ID), serie.Title),) if update_episode: season.update() self.movies.append((season, serie.Title), ) for episode in season.episodes: if episode.Title == self.description: found = (season, episode.episode_number) self.selected_serie_index = len(self.movies) - 1 if self.description: self.searchTitle = self.searchTitle + " - " + self.description if found[0]: self.showEpisodeList(found[0], found[1]) else: self.showSeriesList() except Exception, e: from Source.Globals import printStackTrace printStackTrace() self["status"].setText(_("Error!\n%s" % e)) self["status"].show() return
def setTitleDescr(self, service, title, descr): try: if service.getPath().endswith(".ts"): meta_file = service.getPath() + ".meta" else: meta_file = service.getPath() + ".ts.meta" # Create new meta for ts files if not os.path.exists(meta_file): if os.path.isfile(service.getPath()): _title = os.path.basename(os.path.splitext(service.getPath())[0]) else: _title = service.getName() _sid = "0:0:0:0:0:0:0:0:0:0:" _descr = "" _time = "" _tags = "" metafile = open(meta_file, "w") metafile.write("%s\n%s\n%s\n%s\n%s" % (_sid, _title, _descr, _time, _tags)) metafile.close() if os.path.exists(meta_file): metafile = open(meta_file, "r") sid = metafile.readline() oldtitle = metafile.readline().rstrip() olddescr = metafile.readline().rstrip() rest = metafile.read() metafile.close() if not title and title != "": title = oldtitle if not descr and descr != "": descr = olddescr metafile = open(meta_file, "w") metafile.write("%s%s\n%s\n%s" % (sid, title, descr, rest)) metafile.close() except: printStackTrace()
def showSeriesDetails(self, movie): serie = movie['Serie'][0] try: self.updateView(self.SHOW_SERIE_DETAIL) overview = serie['Overview'] if overview: overview = overview.encode('utf-8', 'ignore') else: overview = _( "Sorry, no description for '%s' at TheTVDB.com found!" ) % self.name cover_file = self.downloadCover(serie) self.setPoster(cover_file) self["description"].setText(overview) extended = "" first_aired = TheTVDBMain.convert_date(serie['FirstAired']) if first_aired: extended = (_("First Aired: %s") % first_aired) + ' / ' airs_day = serie['Airs_DayOfWeek'] if airs_day: extended += (_("Air Day: %s") % airs_day.encode('utf-8', 'ignore')) + ' / ' else: extended += "" airs_time = TheTVDBMain.convert_time(serie['Airs_Time']) if airs_time: extended += (_("Air Time: %s") % airs_time) + ' / ' runtime = serie['Runtime'] if runtime: extended += (_("Runtime: %s minutes\n") % runtime.encode('utf-8', 'ignore')) network = serie['Network'] if network: extended += (_("Broadcast TV network: %s") % network.encode('utf-8', 'ignore')) + ' / ' else: extended += "" if serie['Genre']: genre = " ,".join(serie['Genre']) extended += (_("Genre: %s\n") % genre.encode('utf-8', 'ignore')) content_rating = serie['ContentRating'] if content_rating: extended += (_("Certification: %s") % content_rating.encode('utf-8', 'ignore')) + ' / ' rating = serie['Rating'] if rating: rating = rating.encode('utf-8', 'ignore') self.ratingstars = int( 10 * round(float(rating.replace(',', '.')), 1)) self["stars"].show() self["stars"].setValue(self.ratingstars) self["no_stars"].show() extended += (_("Rating: %s\n") % rating) if serie['Actors']: genre = " ,".join(serie['Actors']).encode('utf-8', 'ignore') extended += (_("Actors: %s\n") % genre) last_updated = serie['lastupdated'] if last_updated is not None: last_updated = datetime.datetime.fromtimestamp( int(last_updated)) extended += (_("\nLast modified at TheTVDB.com: %s") % last_updated) if extended: self["extended"].setText(extended) user_rating = serie['RatingCount'] if user_rating: self["voted"].setText( _("Voted: %s") % user_rating.encode('utf-8', 'ignore') + ' ' + _("times")) else: self["voted"].setText(_("No user voted!")) except: printStackTrace() self.updateView(self.SHOW_SERIE_NO_RESULT)
def showEpisodeDetails(self, movie): if movie: if movie["EpisodeName"]: name = movie["EpisodeName"].encode('utf-8', 'ignore') self.setTitle( _("Episode details for: %s") % (name + ' / ' + self.searchTitle)) else: self.setTitle(_("Sorry, no episode titel available!")) try: overview = movie['Overview'] if overview: overview = overview.encode('utf-8', 'ignore') else: overview = (_( "Sorry, no description for this episode at TheTVDB.com available!" )) extended = "" director = movie["Director"] if director: if isinstance(director, list): director = " ,".join(director) director = director.replace("|", ", ") extended = (_("Regie: %s") % director.encode('utf-8', 'ignore')) + ' / ' writer = movie["Writer"] if writer: print writer if isinstance(writer, list): writer = " ,".join(writer) if writer.startswith("|"): writer = writer[1:] if writer.endswith("|"): writer = writer[:-1] writer = writer.replace("|", ", ") extended += (_("Writer: %s\n") % writer.encode('utf-8', 'ignore')) guest_stars = movie["GuestStars"] if guest_stars: if isinstance(guest_stars, list): guest_stars = " ,".join(guest_stars) if guest_stars.startswith("|"): guest_stars = guest_stars[1:-1].replace("|", ", ") else: guest_stars = guest_stars.replace("|", ", ") extended += (_("Guest Stars: %s\n") % guest_stars.encode('utf-8', 'ignore')) first_aired = movie["FirstAired"] if first_aired: extended += (_("First Aired: %s") % first_aired.encode('utf-8', 'ignore')) image = movie["filename"] if image: cover_file = self.downloadBanner(image) self.setBanner(cover_file) else: cover_file = "" self.setBanner(cover_file) self["description_episode"].setText(overview) self["extended_episode"].setText(extended) self.updateView(self.SHOW_EPISODE_DETAIL) except: printStackTrace() self.updateView(self.SHOW_EPISODE_NO_RESULT)
def getMovieInfo(self, movie): try: if movie: movie.update() extended = self.getImageIndexText(movie) + '\n' name = movie.Title description = movie.Overview released = movie.ReleaseDate.year certification = movie.Certification runtime = movie.Runtime if description: self["description"].setText(description) else: self["description"].setText( _("No description for '%s' at themoviedb.org found!") % name) if released: extended += str.format("{0} {1} / ", _("Appeared:"), released) if runtime: extended += (_("Runtime: %s minutes") % runtime) + ' / ' if certification: extended += str.format("{0} {1} / ", _("Certification:"), _(certification)) extended += str.format("{0} {1:0.1f}", _("Rating:"), movie.UserRating) self.ratingstars = int(10 * round(movie.UserRating, 1)) if self.ratingstars > 0: self["stars"].setValue(self.ratingstars) if len(movie.Genres) > 0: extended += str.format("\r\n{0} {1}", _("Genre:"), ", ".join(movie.Genres)) if len(movie.Writers) > 0: extended += str.format("\r\n{0} {1}", _("From:"), ", ".join(movie.Writers)) if len(movie.Studios) > 0: extended += str.format("\r\n{0} {1}", _("Studio:"), ", ".join(movie.Studios)) if len(movie.Directors) > 0: extended += str.format("\r\n{0} {1}", _("Director:"), ", ".join(movie.Directors)) if len(movie.Producers) > 0: extended += str.format("\r\n{0} {1}", _("Production:"), ", ".join(movie.Producers)) if len(movie.Cast) > 0: extended += str.format("\r\n{0} {1}", _("Actors:"), ", ".join(movie.Cast)) if movie.Votes != 0: self["vote"].setText( str.format("{0} {1} {2}", _("Voted:"), movie.Votes, _("times"))) else: self["vote"].setText(_("No user voted!")) if extended: self["extended"].setText(extended) else: self["extended"].setText(_("Unknown error!!")) self.updateView(self.SHOW_MOVIE_DETAIL) self.updateCover(movie) except Exception, e: from Source.Globals import printStackTrace printStackTrace() self["status"].setText(_("Error!\n%s" % e)) self["status"].show() return
def getMovieInfo(self, movie): try: if movie: extended = '' name = movie.title.encode('utf-8', 'ignore') description = movie.overview released = movie.releasedate.year rating = movie.userrating runtime = movie.runtime if description: description_text = description.encode('utf-8', 'ignore') self['description'].setText(description_text) else: self['description'].setText( _("No description for ' %s ' at themoviedb.org found!") % name) if released: extended = _('Appeared: %s') % released + ' / ' if runtime: extended += _('Runtime: %s minutes') % runtime + ' / ' certification = tmdb.decodeCertification(movie.releases) if certification: extended += _('Certification: %s') % _( certification) + ' / ' rating = str(movie.userrating) extended += _('Rating: %s\n') % rating self.ratingstars = int( 10 * round(float(rating.replace(',', '.')), 1)) if self.ratingstars > 0: self['stars'].setValue(self.ratingstars) genres = [ x.name.encode('utf-8', 'ignore') for x in movie.genres ] if len(genres) > 0: extended += _('Genre: %s\n') % (', ').join(genres) studios = [ x.name.encode('utf-8', 'ignore') for x in movie.studios ] if len(studios) > 0: extended += _('Studio: %s') % (', ').join(studios) + ' / ' crew = [ x.name.encode('utf-8', 'ignore') for x in movie.crew if x.job == 'Director' ] if len(crew) > 0: extended += _('Director: %s') % (', ').join(crew) + ' / ' crew = [ x.name.encode('utf-8', 'ignore') for x in movie.crew if x.job == 'Producer' ] if len(crew) > 0: extended += _('Production: %s\n') % (', ').join(crew) cast = [x.name.encode('utf-8', 'ignore') for x in movie.cast] if len(cast) > 0: extended += _('Actors: %s\n') % (', ').join(cast) if movie.votes != 0: self['vote'].setText( _('Voted: %s') % str(movie.votes) + ' ' + _('times')) else: self['vote'].setText(_('No user voted!')) if extended: self['extended'].setText(extended) else: self['extended'].setText(_('Unknown error!!')) self.updateView(self.SHOW_MOVIE_DETAIL) self.updateCover(movie) except Exception as e: from Source.Globals import printStackTrace printStackTrace() self['status'].setText(_('Error!\n%s' % e)) self['status'].show() return