def delete_poster(self): session = self.db.Session() movie = session.query(db.Movie).filter_by(movie_id=self._movie_id).first() if not movie: log.error("Cannot delete unknown movie's poster!") return False if gutils.question(_("Are you sure you want to delete this poster?"), self.widgets['window']): image_path = gutils.get_defaultimage_fname(self) handler = self.widgets['movie']['picture'].set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(image_path)) gutils.garbage(handler) update_tree_thumbnail(self, gutils.get_defaultthumbnail_fname(self)) # update in database delete.delete_poster(self, movie.poster_md5) movie.poster_md5 = None session.add(movie) try: session.commit() except Exception, e: session.rollback() log.error("cannot delete poster: %s" % e) return False self.update_statusbar(_("Image has been updated")) self.widgets['add']['delete_poster'].set_sensitive(False) self.widgets['movie']['picture_button'].set_sensitive(False)
def delete_poster(self, movie_id=None): if movie_id is None: movie_id = self._movie_id session = self.db.Session() movie = session.query(db.Movie).filter_by(movie_id=movie_id).first() if not movie: log.error("Cannot delete unknown movie's poster!") return False if gutils.question(_("Are you sure you want to delete this poster?"), self.widgets['window']): # update in database delete.delete_poster(self, movie.poster_md5) movie.poster_md5 = None session.add(movie) try: session.commit() except Exception, e: session.rollback() log.error("cannot delete poster: %s" % e) return False if self._movie_id == movie_id: # only if the current selected movie is the same like that one for removing poster image_path = gutils.get_defaultimage_fname(self) handler = self.widgets['movie']['picture'].set_from_pixbuf( gtk.gdk.pixbuf_new_from_file(image_path)) gutils.garbage(handler) self.widgets['add']['delete_poster'].set_sensitive(False) self.widgets['movie']['picture_button'].set_sensitive(False) # always refresh the treeview entry update_tree_thumbnail(self, gutils.get_defaultthumbnail_fname(self)) self.update_statusbar(_("Image has been updated")) return True
def treeview_clicked(self): if self.initialized is False: return False if self.total: treeselection = self.widgets['treeview'].get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() if tmp_iter is None: log.info('Treeview: no selection') return False number = tmp_model.get_value(tmp_iter, 0) movie = self.db.session.query(db.Movie).filter_by(number=number).first() if movie is None: log.info("Treeview: movie doesn't exists (number=%s)", number) elif self.widgets['poster_window'].flags() & gtk.VISIBLE == gtk.VISIBLE: # poster window is visible filename = None if movie.poster_md5: filename = gutils.get_image_fname(movie.poster_md5, self.db) if not filename: filename = gutils.get_defaultimage_fname(self) self.widgets['big_poster'].set_from_file(filename) for ext in self.extensions: ext.maintree_clicked(treeselection, movie) set_details(self, movie) else: set_details(self, {})
def delete_poster(self, movie_id=None): if movie_id is None: movie_id = self._movie_id session = self.db.Session() movie = session.query(db.Movie).filter_by(movie_id=movie_id).first() if not movie: log.error("Cannot delete unknown movie's poster!") return False if gutils.question(_("Are you sure you want to delete this poster?"), self.widgets["window"]): # update in database delete.delete_poster(self, movie.poster_md5) movie.poster_md5 = None session.add(movie) try: session.commit() except Exception, e: session.rollback() log.error("cannot delete poster: %s" % e) return False if self._movie_id == movie_id: # only if the current selected movie is the same like that one for removing poster image_path = gutils.get_defaultimage_fname(self) handler = self.widgets["movie"]["picture"].set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(image_path)) gutils.garbage(handler) self.widgets["add"]["delete_poster"].set_sensitive(False) self.widgets["movie"]["picture_button"].set_sensitive(False) # always refresh the treeview entry update_tree_thumbnail(self, gutils.get_defaultthumbnail_fname(self)) self.update_statusbar(_("Image has been updated")) return True
def change_poster_new_movie(self, number, filename): try: handler = self.Image.set_from_file(filename) pixbuf = self.Image.get_pixbuf() handler = self.widgets['add']['picture'].set_from_pixbuf(pixbuf.scale_simple(100, 140, 3)) gutils.garbage(handler) self.widgets['add']['image'].set_text(filename) return True except: image = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image) handler = self.widgets['add']['picture'].set_from_pixbuf(self.Image.get_pixbuf()) gutils.garbage(handler) return False
def change_poster_new_movie(self, number, filename): try: handler = self.Image.set_from_file(filename) pixbuf = self.Image.get_pixbuf() handler = self.widgets['add']['picture'].set_from_pixbuf( pixbuf.scale_simple(100, 140, 3)) gutils.garbage(handler) self.widgets['add']['image'].set_text(filename) return True except: image = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image) handler = self.widgets['add']['picture'].set_from_pixbuf( self.Image.get_pixbuf()) gutils.garbage(handler) return False
def treeview_clicked(self): if self.initialized is False: return False if len(self.selected) == 1: movie = self.db.session.query(db.Movie).filter_by(number=int(self.selected[0])).first() if self.widgets['poster_window'].flags() & gtk.VISIBLE == gtk.VISIBLE: # poster window is visible filename = None if movie.poster_md5: filename = gutils.get_image_fname(movie.poster_md5, self.db) if not filename: filename = gutils.get_defaultimage_fname(self) self.widgets['big_poster'].set_from_file(filename) #for ext in self.extensions: #ext.maintree_clicked(treeselection, movie) set_details(self, movie) else: return False
def treeview_clicked(self): if self.initialized is False: return False if len(self.selected) == 1: movie = self.db.session.query( db.Movie).filter_by(number=int(self.selected[0])).first() if self.widgets['poster_window'].flags() & gtk.VISIBLE == gtk.VISIBLE: # poster window is visible filename = None if movie.poster_md5: filename = gutils.get_image_fname(movie.poster_md5, self.db) if not filename: filename = gutils.get_defaultimage_fname(self) self.widgets['big_poster'].set_from_file(filename) #for ext in self.extensions: #ext.maintree_clicked(treeselection, movie) set_details(self, movie) else: return False
def clone_movie(self): session = self.db.Session() treeselection = self.widgets['treeview'].get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() if tmp_iter is None: log.warn("cannot clone movie: no item selected") return False number = tmp_model.get_value(tmp_iter, 0) movie = session.query(db.Movie).filter_by(number=number).first() if movie is None: log.warn("cannot clone movie: Movie(%s) not found", number) return False next_number = gutils.find_next_available(self.db) # integer problem workaround if int(movie.seen) == 1: seen = True else: seen = False new_movie = db.Movie() # TODO: WARNING: loan problems (don't copy volume/collection data until resolved) new_movie.cast = movie.cast new_movie.classification = movie.classification new_movie.vcodec_id = movie.vcodec_id new_movie.barcode = movie.barcode new_movie.cameraman = movie.cameraman new_movie.collection_id = movie.collection_id new_movie.volume_id = movie.volume_id new_movie.color = movie.color new_movie.cond = movie.cond new_movie.country = movie.country new_movie.director = movie.director new_movie.genre = movie.genre new_movie.site = movie.site new_movie.loaned = movie.loaned new_movie.layers = movie.layers new_movie.medium_id = movie.medium_id new_movie.number = next_number new_movie.media_num = movie.media_num new_movie.notes = movie.notes new_movie.o_title = movie.o_title new_movie.plot = movie.plot new_movie.poster_md5 = movie.poster_md5 new_movie.ratio_id = movie.ratio_id new_movie.rating = movie.rating new_movie.region = movie.region new_movie.runtime = movie.runtime new_movie.resolution = movie.resolution new_movie.screenplay = movie.screenplay new_movie.seen = seen new_movie.o_site = movie.o_site new_movie.studio = movie.studio new_movie.title = movie.title new_movie.trailer = movie.trailer new_movie.year = movie.year new_movie.tags = movie.tags new_movie.languages = movie.languages new_movie.loans = movie.loans # save session.add(new_movie) if not commit(session): return False if movie.poster_md5: image_path = gutils.get_image_fname(movie.poster_md5, self.db) if not image_path or not os.path.isfile(image_path): image_path = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image_path) # change_filter calls populate_treeview which updates the status bar quick_filter.change_filter(self)
def populate_with_results(self): w = self.widgets['add'] m_id = None if self.founded_results_id: log.info("self.founded:results_id: %s", self.founded_results_id) m_id = self.founded_results_id else: self.founded_results_id = 0 treeselection = self.widgets['results']['treeview'].get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() if tmp_iter is None: return False m_id = tmp_model.get_value(tmp_iter, 0) self.treemodel_results.clear() self.widgets['results']['window'].hide() plugin_name = 'PluginMovie' + self.active_plugin plugin = __import__(plugin_name) self.movie = plugin.Plugin(m_id) self.movie.locations = self.locations self.movie.config = self.config fields_to_fetch = ['o_title', 'title', 'director', 'plot', 'cast', 'country', 'genre', 'classification', 'studio', 'o_site', 'site', 'trailer', 'year', 'notes', 'runtime', 'image', 'rating', 'screenplay', 'cameraman', 'resolution', 'barcode'] # remove fields that user doesn't want to fetch: (see preferences window) fields_to_fetch = [i for i in fields_to_fetch if self.config.get("s_%s" % i, True, section='add')] if w['cb_only_empty'].get_active(): # only empty fields details = get_details(self) fields_to_fetch = [i for i in fields_to_fetch if details[i] is None or details[i] == 0.0] self.movie.fields_to_fetch = fields_to_fetch if not self.movie.get_movie(w['window']): return None self.movie.parse_movie() if 'year' in fields_to_fetch: w['year'].set_value(int(self.movie.year)) fields_to_fetch.pop(fields_to_fetch.index('year')) if 'runtime' in fields_to_fetch: w['runtime'].set_value(int(self.movie.runtime)) fields_to_fetch.pop(fields_to_fetch.index('runtime')) if 'cast' in fields_to_fetch: cast_buffer = w['cast'].get_buffer() cast_buffer.set_text(gutils.convert_entities(self.movie.cast)) fields_to_fetch.pop(fields_to_fetch.index('cast')) if 'plot' in fields_to_fetch: plot_buffer = w['plot'].get_buffer() plot_buffer.set_text(gutils.convert_entities(self.movie.plot)) fields_to_fetch.pop(fields_to_fetch.index('plot')) if 'notes' in fields_to_fetch: notes_buffer = w['notes'].get_buffer() notes_buffer.set_text(gutils.convert_entities(self.movie.notes)) fields_to_fetch.pop(fields_to_fetch.index('notes')) if 'rating' in fields_to_fetch: if self.movie.rating: w['rating_slider'].set_value(float(self.movie.rating)) fields_to_fetch.pop(fields_to_fetch.index('rating')) # poster if 'image' in fields_to_fetch: if self.movie.image: image = os.path.join(self.locations['temp'], "poster_%s.jpg" % self.movie.image) try: handler = self.Image.set_from_file(image) pixbuf = self.Image.get_pixbuf() w['picture'].set_from_pixbuf(pixbuf.scale_simple(100, 140, 3)) w['image'].set_text(self.movie.image) except: image = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image) w['picture'].set_from_pixbuf(self.Image.get_pixbuf()) else: image = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image) Pixbuf = self.Image.get_pixbuf() w['picture'].set_from_pixbuf(Pixbuf) fields_to_fetch.pop(fields_to_fetch.index('image')) # other fields for i in fields_to_fetch: w[i].set_text(gutils.convert_entities(self.movie[i]))
def set_details(self, item=None):#{{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: self._am_movie_id = item['movie_id'] else: self._am_movie_id = None w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() if 'o_title' in item and item['o_title']: w['o_title'].set_text(item['o_title']) else: w['o_title'].set_text('') if 'title' in item and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if 'number' in item and item['number']: w['number'].set_value(int(item['number'])) else: w['number'].set_value(int(gutils.find_next_available(self.db))) if 'title' in item and item['title']: w['title'].set_text(item['title']) if 'year' in item and item['year']: w['year'].set_value(gutils.digits_only(item['year'], 2100)) else: w['year'].set_value(0) if 'resolution' in item and item['resolution']: if self.config.get('use_resolution_alias', True): w['resolution'].set_text(item['resolution']) elif 'height' in item and item['height'] and 'width' in item and item['width']: w['resolution'].set_text("%dx%d" % (item['width'], item['height'])) else: # failback to 'resolution' w['resolution'].set_text(item['resolution']) else: w['resolution'].set_text('') if 'runtime' in item and item['runtime']: w['runtime'].set_value(gutils.digits_only(item['runtime'])) else: w['runtime'].set_value(0) if 'barcode' in item and item['barcode']: w['barcode'].set_text(item['barcode']) else: w['barcode'].set_text('') if 'cameraman' in item and item['cameraman']: w['cameraman'].set_text(item['cameraman']) else: w['cameraman'].set_text('') if 'screenplay' in item and item['screenplay']: w['screenplay'].set_text(item['screenplay']) else: w['screenplay'].set_text('') if 'country' in item and item['country']: w['country'].set_text(item['country']) else: w['country'].set_text('') if 'classification' in item and item['classification']: w['classification'].set_text(item['classification']) else: w['classification'].set_text('') if 'studio' in item and item['studio']: w['studio'].set_text(item['studio']) else: w['studio'].set_text('') if 'o_site' in item and item['o_site']: w['o_site'].set_text(item['o_site']) else: w['o_site'].set_text('') if 'director' in item and item['director']: w['director'].set_text(item['director']) else: w['director'].set_text('') if 'site' in item and item['site']: w['site'].set_text(item['site']) else: w['site'].set_text('') if 'trailer' in item and item['trailer']: w['trailer'].set_text(item['trailer']) else: w['trailer'].set_text('') if 'genre' in item and item['genre']: w['genre'].set_text(item['genre']) else: w['genre'].set_text('') if 'color' in item and item['color']: w['color'].set_active(gutils.digits_only(item['color'], 3)) else: w['color'].set_active(gutils.digits_only(self.config.get('color', 0, section='defaults'), 3)) if 'layers' in item and item['layers']: w['layers'].set_active(gutils.digits_only(item['layers'], 4)) else: w['layers'].set_active(gutils.digits_only(self.config.get('layers', 0, section='defaults'), 4)) if 'region' in item and item['region'] >= 0: w['region'].set_active(gutils.digits_only(item['region'], 8)) else: w['region'].set_active(gutils.digits_only(self.config.get('region', 0, section='defaults'), 8)) if 'cond' in item and item['cond'] >= 0: w['condition'].set_active(gutils.digits_only(item['cond'], 5)) else: w['condition'].set_active(gutils.digits_only(self.config.get('condition', 0, section='defaults'), 5)) if 'media_num' in item and item['media_num']: w['discs'].set_value(gutils.digits_only(item['media_num'])) else: w['discs'].set_value(1) if 'rating' in item and item['rating']: w['rating_slider'].set_value(gutils.digits_only(item['rating'], 10)) else: w['rating_slider'].set_value(0) if 'seen' in item and item['seen'] is True: w['seen'].set_active(True) else: w['seen'].set_active(False) if 'cast' in item and item['cast']: cast_buffer.set_text(item['cast']) else: cast_buffer.set_text('') if 'notes' in item and item['notes']: notes_buffer.set_text(item['notes']) else: notes_buffer.set_text('') if 'plot' in item and item['plot']: plot_buffer.set_text(item['plot']) else: plot_buffer.set_text('') pos = 0 if 'medium_id' in item and item['medium_id']: pos = gutils.findKey(item['medium_id'], self.media_ids) else: pos = gutils.findKey(int(self.config.get('media', 0, section='defaults')), self.media_ids) if pos is not None: w['media'].set_active(int(pos)) else: w['media'].set_active(0) pos = 0 if 'vcodec_id' in item and item['vcodec_id']: pos = gutils.findKey(item['vcodec_id'], self.vcodecs_ids) else: pos = gutils.findKey(int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids) if pos is not None: w['vcodec'].set_active(int(pos)) else: w['vcodec'].set_active(0) pos = 0 if 'volume_id' in item and item['volume_id']: pos = gutils.findKey(item['volume_id'], self.volume_combo_ids) if pos is not None: w['volume'].set_active(int(pos)) else: w['volume'].set_active(0) pos = 0 if 'collection_id' in item and item['collection_id']: pos = gutils.findKey(item['collection_id'], self.collection_combo_ids) if pos is not None: w['collection'].set_active(int(pos)) else: w['collection'].set_active(0) # tags for tag in self.am_tags: self.am_tags[tag].set_active(False) if 'tags' in item: for tag in item['tags']: i = gutils.findKey(tag.tag_id, self.tags_ids) self.am_tags[i].set_active(True) # languages w['lang_treeview'].get_model().clear() if 'languages' in item and len(item['languages']) > 0: for i in item['languages']: self.create_language_row(i) # poster if 'poster_md5' in item and item['poster_md5']: image_path = gutils.get_image_fname(item["poster_md5"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool w['image'].set_text(item['poster_md5']) elif 'image' in item and item['image']: if len(item['image']) == 32: # md5 image_path = gutils.get_image_fname(item["image"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool else: w['image'].set_text(item['image']) else: image_path = os.path.join(self.locations['posters'], "m_%s.jpg" % item['image']) log.warn("TODO: image=%s", item['image']) else: w['image'].set_text('') image_path = gutils.get_defaultimage_fname(self) if not os.path.isfile(image_path): image_path = gutils.get_defaultimage_fname(self) w['picture'].set_from_file(image_path) w['notebook'].set_current_page(0) w['o_title'].grab_focus()
def delete_poster(self): w = self.widgets['add'] w['image'].set_text('') image_path = gutils.get_defaultimage_fname(self) w['picture'].set_from_file(image_path) w['aremove_poster'].set_sensitive(False)
def set_details(self, item=None):#{{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: self._movie_id = item['movie_id'] else: self._movie_id = None w = self.widgets['movie'] if 'number' in item and item['number']: w['number'].set_text(str(int(item['number']))) else: w['number'].set_text('') if 'title' in item and item['title']: w['title'].set_markup("<b><span size='large'>%s</span></b>" % gutils.html_encode(item['title'])) else: w['title'].set_text('') if 'o_title' in item and item['o_title']: w['o_title'].set_markup("<span size='medium'><i>%s</i></span>" % gutils.html_encode(item['o_title'])) else: w['o_title'].set_text('') if 'director' in item and item['director']: w['director'].set_markup("<i>%s</i>" % gutils.html_encode(item['director'])) else: w['director'].set_text('') if 'plot' in item and item['plot']: w['plot'].set_text(str(item['plot'])) else: w['plot'].set_text('') if 'year' in item and item['year']: w['year'].set_text(str(item['year'])) else: w['year'].set_text('') if 'resolution' in item and item['resolution']: if self.config.get('use_resolution_alias', True): w['resolution'].set_text(item['resolution']) elif 'height' in item and item['height'] and 'width' in item and item['width']: w['resolution'].set_text("%dx%d" % (item['width'], item['height'])) else: # fallback to 'resolution' w['resolution'].set_text(item['resolution']) else: w['resolution'].set_text('') pass if 'runtime' in item and item['runtime']: w['runtime'].set_text(str(int(item['runtime']))) else: w['runtime'].set_text('x') if 'cameraman' in item and item['cameraman']: w['cameraman'].set_markup("<i>%s</i>" % gutils.html_encode(item['cameraman'])) else: w['cameraman'].set_text('') if 'screenplay' in item and item['screenplay']: w['screenplay'].set_markup("<i>%s</i>" % gutils.html_encode(item['screenplay'])) else: w['screenplay'].set_text('') if 'cast' in item and item['cast']: w['cast'].set_text(str(item['cast'])) else: w['cast'].set_text('') if 'country' in item and item['country']: w['country'].set_markup("<i>%s</i>" % gutils.html_encode(item['country'])) else: w['country'].set_text('') if 'genre' in item and item['genre']: w['genre'].set_markup("<i>%s</i>" % gutils.html_encode(item['genre'])) else: w['genre'].set_text('') if 'cond' in item and item['cond']: if str(item['cond']) in [str(i) for i in range(len(self._conditions))]: w['condition'].set_markup("<i>%s</i>" % self._conditions[item['cond']]) else: w['condition'].set_text('') log.info("Wrong value in 'condition' field (movie_id=%s, cond=%s)" % (item['movie_id'], item['cond'])) else: w['condition'].set_text('') if 'region' in item and item['region']: if str(item['region']) in [str(i) for i in range(len(self._regions))]: w['region'].set_markup("<i>%s</i>" % gutils.html_encode(item['region'])) if int(item['region']) < 9: self.widgets['tooltips'].set_tip(w['region'], self._regions[int(item['region'])]) else: log.info("Wrong value in 'region' field (movie_id=%s, region=%s)" % (item['movie_id'], item['region'])) w['region'].set_text('') self.widgets['tooltips'].set_tip(w['region'], self._regions[0]) # N/A else: w['region'].set_text('') self.widgets['tooltips'].set_tip(w['region'], self._regions[0]) # N/A if 'layers' in item and item['layers']: if str(item['layers']) in [str(i) for i in range(len(self._layers))]: w['layers'].set_markup("<i>%s</i>" % self._layers[item['layers']]) else: log.info("Wrong value in 'layers' field (movie_id=%s, layers=%s)" % (item['movie_id'], item['layers'])) w['layers'].set_text('') else: w['layers'].set_text('') if 'color' in item and item['color']: if str(item['color']) in [str(i) for i in range(len(self._colors))]: w['color'].set_markup("<i>%s</i>" % self._colors[item['color']]) else: log.info("Wrong value in 'color' field (movie_id=%s, color=%s)" % (item['movie_id'], item['color'])) w['color'].set_markup('') else: w['color'].set_markup('') if 'classification' in item and item['classification']: w['classification'].set_markup("<i>%s</i>" % gutils.html_encode(item['classification'])) else: w['classification'].set_text('') if 'studio' in item and item['studio']: w['studio'].set_markup("<i>%s</i>" % gutils.html_encode(item['studio'])) else: w['studio'].set_text('') if 'o_site' in item and item['o_site']: self._o_site_url = str(item['o_site']) w['go_o_site_button'].set_sensitive(True) else: self._o_site_url = None w['go_o_site_button'].set_sensitive(False) if 'site' in item and item['site']: self._site_url = str(item['site']) w['go_site_button'].set_sensitive(True) else: self._site_url = None w['go_site_button'].set_sensitive(False) if 'trailer' in item and item['trailer']: self._trailer_url = str(item.trailer) w['go_trailer_button'].set_sensitive(True) else: self._trailer_url = None w['go_trailer_button'].set_sensitive(False) if 'seen' in item and item['seen'] == True: w['seen_icon'].set_from_file(os.path.join(self.locations['images'], 'seen.png')) else: w['seen_icon'].set_from_file(os.path.join(self.locations['images'], 'unseen.png')) if 'notes' in item and item['notes']: w['notes'].set_text(str(item.notes)) else: w['notes'].set_text('') tmp = '' if 'media_num' in item and item['media_num']: tmp = str(item.media_num) else: tmp = '0' if 'medium_id' in item and item['medium_id']: if item.medium is not None: tmp += ' x ' + item.medium.name else: pass w['medium'].set_markup("<i>%s</i>" % gutils.html_encode(tmp)) if 'vcodec_id' in item: if item.vcodec is not None: w['vcodec'].set_markup("<i>%s</i>" % gutils.html_encode(item.vcodec.name)) else: w['vcodec'].set_text('') else: w['vcodec'].set_text('') # TODO: add widgets in main and edit windows #if 'ratio_id' in item: # if item.ratio is not None: # w['ratio'].set_markup("<i>%s</i>" % gutils.html_encode(item.ratio.name)) # else: # w['ratio'].set_text('') #else: # w['ratio'].set_text('') # poster if 'poster_md5' in item and item['poster_md5']: filename = gutils.get_image_fname(item['poster_md5'], self.db, 'm') if filename and os.path.isfile(filename): image_path = filename self.widgets['add']['delete_poster'].set_sensitive(True) w['picture_button'].set_sensitive(True) else: image_path = gutils.get_defaultimage_fname(self) self.widgets['add']['delete_poster'].set_sensitive(False) w['picture_button'].set_sensitive(False) else: image_path = gutils.get_defaultimage_fname(self) w['picture_button'].set_sensitive(False) w['picture'].set_from_file(image_path) # ratig rimage = int(self.config.get('rating_image', 0)) if rimage: prefix = '' else: prefix = 'meter' if 'rating' in item and item['rating']: rating_file = "%s/%s0%d.png" % (self.locations['images'], prefix, item['rating']) else: rating_file = "%s/%s0%d.png" % (self.locations['images'], prefix, 0) handler = w['image_rating'].set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(rating_file)) gutils.garbage(handler) # check loan status and adjust buttons and history box if 'loaned' in item and item['loaned'] is True: self.widgets['popups']['loan'].set_sensitive(False) self.widgets['popups']['email'].set_sensitive(True) self.widgets['popups']['return'].set_sensitive(True) self.widgets['menu']['loan'].set_sensitive(False) self.widgets['menu']['email'].set_sensitive(True) self.widgets['menu']['return'].set_sensitive(True) w['loan_button'].set_sensitive(False) w['email_reminder_button'].set_sensitive(True) w['return_button'].set_sensitive(True) if getattr(item, 'loan_details', None) is None: log.warning("movie has no loan data, changing 'loaned' flag to False (movie_id: %s)", item['movie_id']) item.loaned = False else: self.person_name = item.loan_details.person.name self.person_email = item.loan_details.person.email self.loan_date = str(item.loan_details.date) w['loan_info'].set_use_markup(False) w['loan_info'].set_label(_("This movie has been loaned to %s on %s") % (self.person_name, self.loan_date[:10])) if 'loaned' in item and not item['loaned']: # "loaned" status can be changed above, so don't use "else:" in this line self.widgets['popups']['loan'].set_sensitive(True) self.widgets['popups']['email'].set_sensitive(False) self.widgets['popups']['return'].set_sensitive(False) self.widgets['menu']['loan'].set_sensitive(True) self.widgets['menu']['email'].set_sensitive(False) self.widgets['menu']['return'].set_sensitive(False) w['return_button'].set_sensitive(False) w['email_reminder_button'].set_sensitive(False) w['loan_button'].set_sensitive(True) w['loan_info'].set_markup("<b>%s</b>" % _("Movie not loaned")) # loan history self.loans_treemodel.clear() if getattr(item, 'loan_history', None) is not None: for loan in item.loan_history: myiter = self.loans_treemodel.append(None) self.loans_treemodel.set_value(myiter, 0, '%s' % str(loan.date)[:10]) if loan.return_date and loan.return_date != '': self.loans_treemodel.set_value(myiter, 1, str(loan.return_date)[:10]) else: self.loans_treemodel.set_value(myiter, 1, "---") person = self.db.session.query(db.Person.name).filter_by(person_id=loan.person.person_id).first() self.loans_treemodel.set_value(myiter, 2, person.name) # volumes/collections if 'volume_id' in item and item['volume_id'] > 0: if 'volume' in item and item['volume']: w['volume'].set_markup("<b>%s</b>" % gutils.html_encode(item['volume'].name)) w['show_volume_button'].set_sensitive(True) else: w['volume'].set_text('') w['show_volume_button'].set_sensitive(False) else: w['volume'].set_text('') w['show_volume_button'].set_sensitive(False) if 'collection_id' in item and item['collection_id'] > 0: if 'collection' in item and item['collection']: w['collection'].set_markup("<b>%s</b>" % gutils.html_encode(item['collection'].name)) w['show_collection_button'].set_sensitive(True) else: w['collection'].set_text('') w['show_collection_button'].set_sensitive(False) else: w['collection'].set_text('') w['show_collection_button'].set_sensitive(False) # languages for i in w['audio_vbox'].get_children(): i.destroy() for i in w['subtitle_vbox'].get_children(): i.destroy() if 'languages' in item and len(item['languages']) > 0: for i in item['languages']: if i.type == 3: # subtitles if i.subformat: tmp = "%s - %s" % (i.language.name, i.subformat.name) else: tmp = "%s" % i.language.name w['subtitle_vbox'].pack_start(gtk.Label(tmp)) else: language = i.language.name if i.type is not None and len(self._lang_types[i.type]) > 0: language += " <i>%s</i>" % self._lang_types[i.type] tmp = '' if i.achannel: tmp = i.achannel.name if i.acodec: if len(tmp) > 0: tmp += ", %s" % i.acodec.name else: tmp = i.acodec.name if len(tmp) > 0: tmp = "%s (%s)" % (language, tmp) else: tmp = language widget = gtk.Label(tmp) widget.set_use_markup(True) w['audio_vbox'].pack_start(widget) w['audio_vbox'].show_all() w['subtitle_vbox'].show_all() #tags if 'tags' in item: tmp = '' for tag in item['tags']: tmp += "%s, " % tag.name tmp = tmp[:-2] # cut last comma w['tags'].set_text(tmp)
def set_details(self, item=None): # {{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: self._movie_id = item['movie_id'] else: self._movie_id = None w = self.widgets['movie'] if 'number' in item and item['number']: w['number'].set_text(str(int(item['number']))) else: w['number'].set_text('') if 'title' in item and item['title']: w['title'].set_markup("<b><span size='large'>%s</span></b>" % gutils.html_encode(item['title'])) else: w['title'].set_text('') if 'o_title' in item and item['o_title']: w['o_title'].set_markup("<span size='medium'><i>%s</i></span>" % gutils.html_encode(item['o_title'])) else: w['o_title'].set_text('') if 'director' in item and item['director']: w['director'].set_markup("<i>%s</i>" % gutils.html_encode(item['director'])) else: w['director'].set_text('') if 'plot' in item and item['plot']: w['plot'].set_text(str(item['plot'])) else: w['plot'].set_text('') if 'year' in item and item['year']: w['year'].set_text(str(item['year'])) else: w['year'].set_text('') if 'resolution' in item and item['resolution']: if self.config.get('use_resolution_alias', True): w['resolution'].set_text(item['resolution']) elif 'height' in item and item['height'] and 'width' in item and item[ 'width']: w['resolution'].set_text("%dx%d" % (item['width'], item['height'])) else: # fallback to 'resolution' w['resolution'].set_text(item['resolution']) else: w['resolution'].set_text('') pass if 'runtime' in item and item['runtime']: w['runtime'].set_text(str(int(item['runtime']))) else: w['runtime'].set_text('x') if 'cameraman' in item and item['cameraman']: w['cameraman'].set_markup("<i>%s</i>" % gutils.html_encode(item['cameraman'])) else: w['cameraman'].set_text('') if 'screenplay' in item and item['screenplay']: w['screenplay'].set_markup("<i>%s</i>" % gutils.html_encode(item['screenplay'])) else: w['screenplay'].set_text('') if 'cast' in item and item['cast']: w['cast'].set_text(str(item['cast'])) else: w['cast'].set_text('') if 'country' in item and item['country']: w['country'].set_markup("<i>%s</i>" % gutils.html_encode(item['country'])) else: w['country'].set_text('') if 'genre' in item and item['genre']: w['genre'].set_markup("<i>%s</i>" % gutils.html_encode(item['genre'])) else: w['genre'].set_text('') if 'cond' in item and item['cond']: if str(item['cond']) in [str(i) for i in range(len(self._conditions))]: w['condition'].set_markup("<i>%s</i>" % self._conditions[item['cond']]) else: w['condition'].set_text('') log.info( "Wrong value in 'condition' field (movie_id=%s, cond=%s)" % (item['movie_id'], item['cond'])) else: w['condition'].set_text('') if 'region' in item and item['region']: if item['region'] < len(self._regions): w['region'].set_markup( "<i>%s</i>" % gutils.html_encode(self._regions[item['region']])) if int(item['region']) < 12: self.widgets['tooltips'].set_tip( w['region'], self._regions[int(item['region'])]) else: log.info("Wrong value in 'region' field (movie_id=%s, region=%s)" % (item['movie_id'], item['region'])) w['region'].set_text('') self.widgets['tooltips'].set_tip(w['region'], self._regions[0]) # N/A else: w['region'].set_text('') self.widgets['tooltips'].set_tip(w['region'], self._regions[0]) # N/A if 'layers' in item and item['layers']: if str(item['layers']) in [str(i) for i in range(len(self._layers))]: w['layers'].set_markup("<i>%s</i>" % self._layers[item['layers']]) else: log.info("Wrong value in 'layers' field (movie_id=%s, layers=%s)" % (item['movie_id'], item['layers'])) w['layers'].set_text('') else: w['layers'].set_text('') if 'color' in item and item['color']: if str(item['color']) in [str(i) for i in range(len(self._colors))]: w['color'].set_markup("<i>%s</i>" % self._colors[item['color']]) else: log.info("Wrong value in 'color' field (movie_id=%s, color=%s)" % (item['movie_id'], item['color'])) w['color'].set_markup('') else: w['color'].set_markup('') if 'classification' in item and item['classification']: w['classification'].set_markup( "<i>%s</i>" % gutils.html_encode(item['classification'])) else: w['classification'].set_text('') if 'studio' in item and item['studio']: w['studio'].set_markup("<i>%s</i>" % gutils.html_encode(item['studio'])) else: w['studio'].set_text('') if 'o_site' in item and item['o_site']: self._o_site_url = str(item['o_site']) w['go_o_site_button'].set_sensitive(True) else: self._o_site_url = None w['go_o_site_button'].set_sensitive(False) if 'site' in item and item['site']: self._site_url = str(item['site']) w['go_site_button'].set_sensitive(True) else: self._site_url = None w['go_site_button'].set_sensitive(False) if 'trailer' in item and item['trailer']: self._trailer_url = str(item.trailer) w['go_trailer_button'].set_sensitive(True) else: self._trailer_url = None w['go_trailer_button'].set_sensitive(False) if 'seen' in item and item['seen'] == True: w['seen_icon'].set_from_file( os.path.join(self.locations['images'], 'seen.png')) else: w['seen_icon'].set_from_file( os.path.join(self.locations['images'], 'unseen.png')) if 'notes' in item and item['notes']: w['notes'].set_text(str(item.notes)) else: w['notes'].set_text('') tmp = '' if 'media_num' in item and item['media_num']: tmp = str(item.media_num) else: tmp = '0' if 'medium_id' in item and item['medium_id']: if item.medium is not None: tmp += ' x ' + item.medium.name else: pass w['medium'].set_markup("<i>%s</i>" % gutils.html_encode(tmp)) if 'vcodec_id' in item: if item.vcodec is not None: w['vcodec'].set_markup("<i>%s</i>" % gutils.html_encode(item.vcodec.name)) else: w['vcodec'].set_text('') else: w['vcodec'].set_text('') # TODO: add widgets in main and edit windows #if 'ratio_id' in item: # if item.ratio is not None: # w['ratio'].set_markup("<i>%s</i>" % gutils.html_encode(item.ratio.name)) # else: # w['ratio'].set_text('') #else: # w['ratio'].set_text('') # poster if 'poster_md5' in item and item['poster_md5']: filename = gutils.get_image_fname(item['poster_md5'], self.db, 'm') if filename and os.path.isfile(filename): image_path = filename self.widgets['add']['delete_poster'].set_sensitive(True) w['picture_button'].set_sensitive(True) else: image_path = gutils.get_defaultimage_fname(self) self.widgets['add']['delete_poster'].set_sensitive(False) w['picture_button'].set_sensitive(False) else: image_path = gutils.get_defaultimage_fname(self) self.widgets['add']['delete_poster'].set_sensitive(False) w['picture_button'].set_sensitive(False) w['picture'].set_from_file(image_path) # ratig rimage = int(self.config.get('rating_image', 0)) if rimage: prefix = '' else: prefix = 'meter' if 'rating' in item and item['rating']: rating_file = "%s/%s0%d.png" % (self.locations['images'], prefix, item['rating']) else: rating_file = "%s/%s0%d.png" % (self.locations['images'], prefix, 0) handler = w['image_rating'].set_from_pixbuf( gtk.gdk.pixbuf_new_from_file(rating_file)) gutils.garbage(handler) # check loan status and adjust buttons and history box if 'loaned' in item and item['loaned'] is True: self.widgets['popups']['loan'].set_sensitive(False) self.widgets['popups']['email'].set_sensitive(True) self.widgets['popups']['return'].set_sensitive(True) self.widgets['menu']['loan'].set_sensitive(False) self.widgets['menu']['email'].set_sensitive(True) self.widgets['menu']['return'].set_sensitive(True) w['loan_button'].set_sensitive(False) w['email_reminder_button'].set_sensitive(True) w['return_button'].set_sensitive(True) if getattr(item, 'loan_details', None) is None: log.warning( "movie has no loan data, changing 'loaned' flag to False (movie_id: %s)", item['movie_id']) item.loaned = False else: self.person_name = item.loan_details.person.name self.person_email = item.loan_details.person.email self.loan_date = str(item.loan_details.date) w['loan_info'].set_use_markup(False) w['loan_info'].set_label( _("This movie has been loaned to %s on %s") % (self.person_name, self.loan_date[:10])) if 'loaned' in item and not item[ 'loaned']: # "loaned" status can be changed above, so don't use "else:" in this line self.widgets['popups']['loan'].set_sensitive(True) self.widgets['popups']['email'].set_sensitive(False) self.widgets['popups']['return'].set_sensitive(False) self.widgets['menu']['loan'].set_sensitive(True) self.widgets['menu']['email'].set_sensitive(False) self.widgets['menu']['return'].set_sensitive(False) w['return_button'].set_sensitive(False) w['email_reminder_button'].set_sensitive(False) w['loan_button'].set_sensitive(True) w['loan_info'].set_markup("<b>%s</b>" % _("Movie not loaned")) # loan history self.loans_treemodel.clear() if getattr(item, 'loan_history', None) is not None: for loan in item.loan_history: myiter = self.loans_treemodel.append(None) self.loans_treemodel.set_value(myiter, 0, '%s' % str(loan.date)[:10]) if loan.return_date and loan.return_date != '': self.loans_treemodel.set_value(myiter, 1, str(loan.return_date)[:10]) else: self.loans_treemodel.set_value(myiter, 1, "---") if loan.person: person = self.db.session.query(db.Person.name).filter_by( person_id=loan.person.person_id).first() self.loans_treemodel.set_value(myiter, 2, person.name) # volumes/collections if 'volume_id' in item and item['volume_id'] > 0: if 'volume' in item and item['volume']: w['volume'].set_markup("<b>%s</b>" % gutils.html_encode(item['volume'].name)) w['show_volume_button'].set_sensitive(True) else: w['volume'].set_text('') w['show_volume_button'].set_sensitive(False) else: w['volume'].set_text('') w['show_volume_button'].set_sensitive(False) if 'collection_id' in item and item['collection_id'] > 0: if 'collection' in item and item['collection']: w['collection'].set_markup( "<b>%s</b>" % gutils.html_encode(item['collection'].name)) w['show_collection_button'].set_sensitive(True) else: w['collection'].set_text('') w['show_collection_button'].set_sensitive(False) else: w['collection'].set_text('') w['show_collection_button'].set_sensitive(False) # languages for i in w['audio_vbox'].get_children(): i.destroy() for i in w['subtitle_vbox'].get_children(): i.destroy() if 'languages' in item and len(item['languages']) > 0: for i in item['languages']: if i.type == 3: # subtitles if i.subformat: tmp = "%s - %s" % (i.language.name, i.subformat.name) else: tmp = "%s" % i.language.name w['subtitle_vbox'].pack_start(gtk.Label(tmp)) else: language = i.language.name if i.type is not None and len(self._lang_types[i.type]) > 0: language += " <i>%s</i>" % self._lang_types[i.type] tmp = '' if i.achannel: tmp = i.achannel.name if i.acodec: if len(tmp) > 0: tmp += ", %s" % i.acodec.name else: tmp = i.acodec.name if len(tmp) > 0: tmp = "%s (%s)" % (language, tmp) else: tmp = language widget = gtk.Label(tmp) widget.set_use_markup(True) w['audio_vbox'].pack_start(widget) w['audio_vbox'].show_all() w['subtitle_vbox'].show_all() #tags if 'tags' in item: tmp = '' for tag in item['tags']: tmp += "%s, " % tag.name tmp = tmp[:-2] # cut last comma w['tags'].set_text(tmp)
def populate_with_results(self): w = self.widgets['add'] m_id = None if self.founded_results_id: log.info("selected id: %s", self.founded_results_id) m_id = self.founded_results_id else: self.founded_results_id = 0 treeselection = self.widgets['results']['treeview'].get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() if tmp_iter is None: return False m_id = tmp_model.get_value(tmp_iter, 0) self.treemodel_results.clear() self.widgets['results']['window'].hide() plugin_name = 'PluginMovie' + self.active_plugin plugin = __import__(plugin_name) self.movie = plugin.Plugin(m_id) self.movie.locations = self.locations self.movie.config = self.config fields_to_fetch = [ 'o_title', 'title', 'director', 'plot', 'cast', 'country', 'genre', 'classification', 'studio', 'o_site', 'site', 'trailer', 'year', 'notes', 'runtime', 'image', 'rating', 'screenplay', 'cameraman', 'resolution', 'barcode' ] # remove fields that user doesn't want to fetch: (see preferences window) fields_to_fetch = [ i for i in fields_to_fetch if self.config.get("s_%s" % i, True, section='add') ] if w['cb_only_empty'].get_active(): # only empty fields details = get_details(self) fields_to_fetch = [ i for i in fields_to_fetch if details[i] is None or details[i] == 0.0 ] self.movie.fields_to_fetch = fields_to_fetch if not self.movie.get_movie(w['window']): return None self.movie.parse_movie() if 'year' in fields_to_fetch: w['year'].set_value(int(self.movie.year)) fields_to_fetch.pop(fields_to_fetch.index('year')) if 'runtime' in fields_to_fetch: w['runtime'].set_value(int(self.movie.runtime)) fields_to_fetch.pop(fields_to_fetch.index('runtime')) if 'cast' in fields_to_fetch: cast_buffer = w['cast'].get_buffer() cast_buffer.set_text(gutils.convert_entities(self.movie.cast)) fields_to_fetch.pop(fields_to_fetch.index('cast')) if 'plot' in fields_to_fetch: plot_buffer = w['plot'].get_buffer() plot_buffer.set_text(gutils.convert_entities(self.movie.plot)) fields_to_fetch.pop(fields_to_fetch.index('plot')) if 'notes' in fields_to_fetch: notes_buffer = w['notes'].get_buffer() notes_buffer.set_text(gutils.convert_entities(self.movie.notes)) fields_to_fetch.pop(fields_to_fetch.index('notes')) if 'rating' in fields_to_fetch: if self.movie.rating: w['rating_slider'].set_value(float(self.movie.rating)) fields_to_fetch.pop(fields_to_fetch.index('rating')) if 'resolution' in fields_to_fetch: w['resolution'].get_child().set_text( gutils.convert_entities(self.movie.resolution)) fields_to_fetch.pop(fields_to_fetch.index('resolution')) # poster if 'image' in fields_to_fetch: w['image'].set_text('') if self.movie.image: image = os.path.join(self.locations['temp'], "poster_%s.jpg" % self.movie.image) try: handler = self.Image.set_from_file(image) pixbuf = self.Image.get_pixbuf() w['picture'].set_from_pixbuf(pixbuf.scale_simple(100, 140, 3)) w['image'].set_text(self.movie.image) w['aremove_poster'].set_sensitive(True) except: image = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image) w['picture'].set_from_pixbuf(self.Image.get_pixbuf()) w['aremove_poster'].set_sensitive(False) else: image = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image) Pixbuf = self.Image.get_pixbuf() w['picture'].set_from_pixbuf(Pixbuf) w['aremove_poster'].set_sensitive(False) fields_to_fetch.pop(fields_to_fetch.index('image')) # other fields for i in fields_to_fetch: w[i].set_text(gutils.convert_entities(self.movie[i]))
def clone_movie(self): session = self.db.Session() if self.selected_iter[0] is None: log.warn("cannot clone movie: no item selected") return False movie = session.query(db.Movie).filter_by(number=self.selected[0]).first() if movie is None: log.warn("cannot clone movie: Movie(%s) not found", number) return False next_number = gutils.find_next_available(self.db) # integer problem workaround if int(movie.seen) == 1: seen = True else: seen = False new_movie = db.Movie() # TODO: WARNING: loan problems (don't copy volume/collection data until resolved) new_movie.cast = movie.cast new_movie.classification = movie.classification new_movie.vcodec_id = movie.vcodec_id new_movie.barcode = movie.barcode new_movie.cameraman = movie.cameraman new_movie.collection_id = movie.collection_id new_movie.volume_id = movie.volume_id new_movie.color = movie.color new_movie.cond = movie.cond new_movie.country = movie.country new_movie.director = movie.director new_movie.genre = movie.genre new_movie.site = movie.site new_movie.loaned = movie.loaned new_movie.layers = movie.layers new_movie.medium_id = movie.medium_id new_movie.number = next_number new_movie.media_num = movie.media_num new_movie.notes = movie.notes new_movie.o_title = movie.o_title new_movie.plot = movie.plot new_movie.poster_md5 = movie.poster_md5 new_movie.ratio_id = movie.ratio_id new_movie.rating = movie.rating new_movie.region = movie.region new_movie.runtime = movie.runtime new_movie.resolution = movie.resolution new_movie.screenplay = movie.screenplay new_movie.seen = seen new_movie.o_site = movie.o_site new_movie.studio = movie.studio new_movie.title = movie.title new_movie.trailer = movie.trailer new_movie.year = movie.year new_movie.tags = movie.tags new_movie.languages = movie.languages new_movie.loans = movie.loans # save session.add(new_movie) if not commit(session): return False if movie.poster_md5: image_path = gutils.get_image_fname(movie.poster_md5, self.db) if not image_path or not os.path.isfile(image_path): image_path = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image_path) # change_filter calls populate_treeview which updates the status bar quick_filter.change_filter(self)
def set_details(self, item=None): #{{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: self._am_movie_id = item['movie_id'] else: self._am_movie_id = None w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() if 'o_title' in item and item['o_title']: w['o_title'].set_text(item['o_title']) else: w['o_title'].set_text('') if 'title' in item and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if 'number' in item and item['number']: w['number'].set_value(int(item['number'])) else: w['number'].set_value(int(gutils.find_next_available(self.db))) if 'title' in item and item['title']: w['title'].set_text(item['title']) if 'year' in item and item['year']: w['year'].set_value(gutils.digits_only(item['year'], 2100)) else: w['year'].set_value(0) if 'resolution' in item and item['resolution']: if self.config.get('use_resolution_alias', True): w['resolution'].get_child().set_text(item['resolution']) elif 'height' in item and item['height'] and 'width' in item and item[ 'width']: w['resolution'].get_child().set_text( "%dx%d" % (item['width'], item['height'])) else: # failback to 'resolution' w['resolution'].get_child().set_text(item['resolution']) else: w['resolution'].get_child().set_text('') if 'runtime' in item and item['runtime']: w['runtime'].set_value(gutils.digits_only(item['runtime'])) else: w['runtime'].set_value(0) if 'barcode' in item and item['barcode']: w['barcode'].set_text(item['barcode']) else: w['barcode'].set_text('') if 'cameraman' in item and item['cameraman']: w['cameraman'].set_text(item['cameraman']) else: w['cameraman'].set_text('') if 'screenplay' in item and item['screenplay']: w['screenplay'].set_text(item['screenplay']) else: w['screenplay'].set_text('') if 'country' in item and item['country']: w['country'].set_text(item['country']) else: w['country'].set_text('') if 'classification' in item and item['classification']: w['classification'].set_text(item['classification']) else: w['classification'].set_text('') if 'studio' in item and item['studio']: w['studio'].set_text(item['studio']) else: w['studio'].set_text('') if 'o_site' in item and item['o_site']: w['o_site'].set_text(item['o_site']) else: w['o_site'].set_text('') if 'director' in item and item['director']: w['director'].set_text(item['director']) else: w['director'].set_text('') if 'site' in item and item['site']: w['site'].set_text(item['site']) else: w['site'].set_text('') if 'trailer' in item and item['trailer']: w['trailer'].set_text(item['trailer']) else: w['trailer'].set_text('') if 'genre' in item and item['genre']: w['genre'].set_text(item['genre']) else: w['genre'].set_text('') if 'color' in item and item['color']: w['color'].set_active(gutils.digits_only(item['color'], 3)) else: w['color'].set_active( gutils.digits_only(self.config.get('color', 0, section='defaults'), 3)) if 'layers' in item and item['layers']: w['layers'].set_active(gutils.digits_only(item['layers'], 4)) else: w['layers'].set_active( gutils.digits_only( self.config.get('layers', 0, section='defaults'), 4)) if 'region' in item and item['region'] >= 0: w['region'].set_active(gutils.digits_only(item['region'], 11)) else: w['region'].set_active( gutils.digits_only( self.config.get('region', 0, section='defaults'), 11)) if 'cond' in item and item['cond'] >= 0: w['condition'].set_active(gutils.digits_only(item['cond'], 5)) else: w['condition'].set_active( gutils.digits_only( self.config.get('condition', 0, section='defaults'), 5)) if 'media_num' in item and item['media_num']: w['discs'].set_value(gutils.digits_only(item['media_num'])) else: w['discs'].set_value(1) if 'rating' in item and item['rating']: w['rating_slider'].set_value(gutils.digits_only(item['rating'], 10)) else: w['rating_slider'].set_value(0) if 'seen' in item: if item['seen'] is True: w['seen'].set_active(True) else: w['seen'].set_active(False) else: w['seen'].set_active( bool(self.config.get('seen', True, section='defaults'))) if 'cast' in item and item['cast']: cast_buffer.set_text(item['cast']) else: cast_buffer.set_text('') if 'notes' in item and item['notes']: notes_buffer.set_text(item['notes']) else: notes_buffer.set_text('') if 'plot' in item and item['plot']: plot_buffer.set_text(item['plot']) else: plot_buffer.set_text('') pos = 0 if 'medium_id' in item and item['medium_id']: pos = gutils.findKey(item['medium_id'], self.media_ids) else: pos = gutils.findKey( int(self.config.get('media', 0, section='defaults')), self.media_ids) if pos is not None: w['media'].set_active(int(pos)) else: w['media'].set_active(0) pos = 0 if 'vcodec_id' in item and item['vcodec_id']: pos = gutils.findKey(item['vcodec_id'], self.vcodecs_ids) else: pos = gutils.findKey( int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids) if pos is not None: w['vcodec'].set_active(int(pos)) else: w['vcodec'].set_active(0) pos = 0 if 'volume_id' in item and item['volume_id']: pos = gutils.findKey(item['volume_id'], self.volume_combo_ids) if pos is not None: w['volume'].set_active(int(pos)) else: w['volume'].set_active(0) pos = 0 if 'collection_id' in item and item['collection_id']: pos = gutils.findKey(item['collection_id'], self.collection_combo_ids) if pos is not None: w['collection'].set_active(int(pos)) else: w['collection'].set_active(0) # tags for tag in self.am_tags: self.am_tags[tag].set_active(False) if 'tags' in item: for tag in item['tags']: i = gutils.findKey(tag.tag_id, self.tags_ids) self.am_tags[i].set_active(True) # languages w['lang_treeview'].get_model().clear() if 'languages' in item and len(item['languages']) > 0: for i in item['languages']: self.create_language_row(i) # poster w['aremove_poster'].set_sensitive(True) if 'poster_md5' in item and item['poster_md5']: image_path = gutils.get_image_fname(item["poster_md5"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool w['aremove_poster'].set_sensitive(False) w['image'].set_text(item['poster_md5']) elif 'image' in item and item['image']: if len(item['image']) == 32: # md5 image_path = gutils.get_image_fname(item["image"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool w['aremove_poster'].set_sensitive(False) else: w['image'].set_text(item['image']) else: image_path = os.path.join(self.locations['posters'], "m_%s.jpg" % item['image']) log.warn("TODO: image=%s", item['image']) else: w['image'].set_text('') image_path = gutils.get_defaultimage_fname(self) w['aremove_poster'].set_sensitive(False) if not os.path.isfile(image_path): image_path = gutils.get_defaultimage_fname(self) w['aremove_poster'].set_sensitive(False) w['picture'].set_from_file(image_path) w['notebook'].set_current_page(0) w['o_title'].grab_focus()