def play(self, config=None): status = "Selected %s" % self.path loader = MetadataLoader.get_loader(self.metadata) with open(self.path) as fh: data = fh.read() loader.save_poster(self.metadata, self.url, data) self.config.show_status(status)
def draw_mmdb(self, item, m): self.clear() metadata = m['mmdb'] season = m.get('season', None) loader = MetadataLoader.get_loader(metadata) imgpath = loader.get_poster(metadata, season=season) print "draw_mmdb: %s, type=%s" % (imgpath, type(imgpath)) image = self.window.get_image(imgpath) y = self.y + self.h - image.height self.window.blit(image, self.x, y, 0) self.window.draw_markup(metadata.get_markup(m.get('media_file', None)), self.window.detail_font, x=self.x + image.width + 10, y=self.y + self.h, anchor_x='left', anchor_y='top', width=self.w - image.width - 10) icon_codes = metadata.get_icon_codes(m.get('media_file', None)) print icon_codes x = self.x for icon_code in icon_codes: imgpath = loader.get_icon(icon_code) if imgpath is None: continue print imgpath image = self.window.get_image(imgpath) self.window.blit(image, x, y - image.height-10, 0) x += image.width + 10
def __init__(self, parent, config, result, orig_title_key): MMDBPopulator.__init__(self, config) self.parent = parent self.result = result self.title_key = TitleKey(orig_title_key.category, orig_title_key.subcategory, result['title'], result['year']) self.loader = MetadataLoader.get_loader(self.title_key) self.metadata = self.loader.get_basic_metadata(self.title_key, self.result) self.first_time = True
def iter_create(self): media_files = list(self.get_media()) if len(media_files) > 0: title_key = media_files[0].scan.title_key loader = MetadataLoader.get_loader(self.metadata) guesses = loader.search(title_key) for result in guesses: yield result['title'], ChangeImdb(self, self.config, result, title_key)
def update_posters(self): for title_key, metadata in self.title_keys_with_metadata(): loader = MetadataLoader.get_loader(title_key) if loader.has_poster(metadata): log.debug("Have poster for %s" % unicode(metadata).encode('utf-8')) else: log.debug("Loading poster for %s" % unicode(metadata).encode('utf-8')) loader.fetch_posters(metadata)
def iter_image_path(self): for metadata in self.get_sorted_metadata(): try: loader = MetadataLoader.get_loader(metadata) imgpath = loader.get_poster(metadata) if imgpath is not None: yield imgpath except RuntimeError: print "No loader for %s" % str(metadata)
def draw_imdb_search_result(self, item, m): self.clear() result = m['imdb_search_result'] print result metadata = m['metadata'] loader = MetadataLoader.get_loader(metadata) imgpath = loader.get_poster(metadata) image = self.window.get_image(imgpath) self.window.blit(image, self.x, self.h - image.height, 0) akas = "\n".join([a.replace('::', ' -- ') for a in result.get('akas',[])]) text = u"""<b>Title:</b> %s <b>ID:</b> %s <b>Year:</b> %s <b>Type:</b> %s <b>Also known as:</b> %s """ % (result['title'], metadata.id, result['year'], result['kind'], akas) self.window.draw_markup(text, self.window.detail_font, x=self.x + image.width + 10, y=self.h, anchor_x='left', anchor_y='top', width=self.w - image.width - 10)
def iter_create(self): loader = MetadataLoader.get_loader(self.metadata) posters = loader.get_known_posters(self.metadata) if len(posters) > 0: for url, path in posters: yield os.path.basename(path), ChangePoster(self, self.config, self.metadata, url, path)