def parse_movie(self): try: fields = list(self.fields_to_fetch) # make a copy self.initialize() if 'year' in fields: self.get_year() self.year = gutils.digits_only(self.year, 2100) fields.pop(fields.index('year')) if 'runtime' in fields: self.get_runtime() self.runtime = gutils.digits_only(self.runtime) fields.pop(fields.index('runtime')) if 'rating' in fields: self.get_rating() self.rating = gutils.digits_only(self.rating, 10) fields.pop(fields.index('rating')) if 'cast' in fields: self.get_cast() self.cast = gutils.clean(self.cast) if not isinstance(self.cast, unicode): self.cast = gutils.gdecode(self.cast, self.encode) fields.pop(fields.index('cast')) if 'plot' in fields: self.get_plot() self.plot = gutils.clean(self.plot) if not isinstance(self.plot, unicode): self.plot = gutils.gdecode(self.plot, self.encode) fields.pop(fields.index('plot')) if 'notes' in fields: self.get_notes() self.notes = gutils.clean(self.notes) if not isinstance(self.notes, unicode): self.notes = gutils.gdecode(self.notes, self.encode) fields.pop(fields.index('notes')) if 'image' in fields: self.get_image() self.fetch_picture() fields.pop(fields.index('image')) for i in fields: getattr(self, "get_%s" % i)() self[i] = gutils.clean(self[i]) if not isinstance(self[i], unicode): self[i] = gutils.gdecode(self[i], self.encode) if 'o_title' in self.fields_to_fetch and self.o_title is not None: if self.o_title[:4] == u'The ': self.o_title = self.o_title[4:] + u', The' if 'title' in self.fields_to_fetch and self.title is not None: if self.title[:4] == u'The ': self.title = self.title[4:] + u', The' except: log.exception('') finally: # close the progress dialog which was opened in get_movie self.progress.hide()
def parse_movie(self): try: fields = list(self.fields_to_fetch) # make a copy self.initialize() if "year" in fields: self.get_year() self.year = gutils.digits_only(self.year, 2100) fields.pop(fields.index("year")) if "runtime" in fields: self.get_runtime() self.runtime = gutils.digits_only(self.runtime) fields.pop(fields.index("runtime")) if "rating" in fields: self.get_rating() self.rating = gutils.digits_only(self.rating, 10) fields.pop(fields.index("rating")) if "cast" in fields: self.get_cast() self.cast = gutils.clean(self.cast) if not isinstance(self.cast, unicode): self.cast = gutils.gdecode(self.cast, self.encode) fields.pop(fields.index("cast")) if "plot" in fields: self.get_plot() self.plot = gutils.clean(self.plot) if not isinstance(self.plot, unicode): self.plot = gutils.gdecode(self.plot, self.encode) fields.pop(fields.index("plot")) if "notes" in fields: self.get_notes() self.notes = gutils.clean(self.notes) if not isinstance(self.notes, unicode): self.notes = gutils.gdecode(self.notes, self.encode) fields.pop(fields.index("notes")) if "image" in fields: self.get_image() self.fetch_picture() fields.pop(fields.index("image")) for i in fields: getattr(self, "get_%s" % i)() self[i] = gutils.clean(self[i]) if not isinstance(self[i], unicode): self[i] = gutils.gdecode(self[i], self.encode) if "o_title" in self.fields_to_fetch and self.o_title is not None: if self.o_title[:4] == u"The ": self.o_title = self.o_title[4:] + u", The" if "title" in self.fields_to_fetch and self.title is not None: if self.title[:4] == u"The ": self.title = self.title[4:] + u", The" finally: # close the progress dialog which was opened in get_movie self.progress.hide()
def parse_movie(self): from copy import deepcopy fields = deepcopy(self.fields_to_fetch) self.initialize() if "year" in fields: self.get_year() self.year = gutils.digits_only(self.year, 2100) fields.pop(fields.index("year")) if "runtime" in fields: self.get_runtime() self.runtime = gutils.digits_only(self.runtime) fields.pop(fields.index("runtime")) if "rating" in fields: self.get_rating() self.rating = gutils.digits_only(self.rating, 10) fields.pop(fields.index("rating")) if "cast" in fields: self.get_cast() self.cast = gutils.clean(self.cast) self.cast = gutils.gdecode(self.cast, self.encode) fields.pop(fields.index("cast")) if "plot" in fields: self.get_plot() self.plot = gutils.clean(self.plot) self.plot = gutils.gdecode(self.plot, self.encode) fields.pop(fields.index("plot")) if "notes" in fields: self.get_notes() self.notes = gutils.clean(self.notes) self.notes = gutils.gdecode(self.notes, self.encode) fields.pop(fields.index("notes")) if "image" in fields: self.get_image() self.fetch_picture() fields.pop(fields.index("image")) for i in fields: getattr(self, "get_%s" % i)() self[i] = gutils.clean(self[i]) self[i] = gutils.gdecode(self[i], self.encode) if "o_title" in self.fields_to_fetch and self.o_title is not None: if self.o_title[:4] == "The ": self.o_title = self.o_title[4:] + ", The" if "title" in self.fields_to_fetch and self.title is not None: if self.title[:4] == "The ": self.title = self.title[4:] + ", The"
def parse_movie(self): from copy import deepcopy fields = deepcopy(self.fields_to_fetch) self.initialize() if 'year' in fields: self.get_year() self.year = gutils.digits_only(self.year, 2100) fields.pop(fields.index('year')) if 'runtime' in fields: self.get_runtime() self.runtime = gutils.digits_only(self.runtime) fields.pop(fields.index('runtime')) if 'rating' in fields: self.get_rating() self.rating = gutils.digits_only(self.rating, 10) fields.pop(fields.index('rating')) if 'cast' in fields: self.get_cast() self.cast = gutils.clean(self.cast) self.cast = gutils.gdecode(self.cast, self.encode) fields.pop(fields.index('cast')) if 'plot' in fields: self.get_plot() self.plot = gutils.clean(self.plot) self.plot = gutils.gdecode(self.plot, self.encode) fields.pop(fields.index('plot')) if 'notes' in fields: self.get_notes() self.notes = gutils.clean(self.notes) self.notes = gutils.gdecode(self.notes, self.encode) fields.pop(fields.index('notes')) if 'image' in fields: self.get_image() self.fetch_picture() fields.pop(fields.index('image')) for i in fields: getattr(self, "get_%s" % i)() self[i] = gutils.clean(self[i]) self[i] = gutils.gdecode(self[i], self.encode) if 'o_title' in self.fields_to_fetch and self.o_title is not None: if self.o_title[:4] == 'The ': self.o_title = self.o_title[4:] + ', The' if 'title' in self.fields_to_fetch and self.title is not None: if self.title[:4] == 'The ': self.title = self.title[4:] + ', The'
def get_rating(self): self.rating = gutils.trim(self.page, '<h5>Nutzer-Bewertung:</h5>', '/10') if self.rating: try: self.rating = str(float(gutils.digits_only(gutils.clean(self.rating)))) except: self.rating = ''
def get_searches(self): elements = string.split(self.page,"<br>") if (elements[0]<>''): for element in elements: elementid = gutils.digits_only( gutils.trim(element,'<a href="view.php?page=film&fid=','">') ) if elementid != 0: self.ids.append(elementid) self.titles.append(gutils.trim(element,'">', '</a>'))
def get_searches(self): elements = string.split(self.page, '<a href="/filmes/') self.number_results = elements[-1] if len(elements[0]): for element in elements: id = gutils.digits_only(gutils.before(element, '"')) title = gutils.clean(re.sub('</div>.*', '', string.replace(gutils.before(gutils.after(element, '>'), '</small>'), '<small>', ' / '))) if id and title and title[0] != '<': self.ids.append(id) self.titles.append(gutils.convert_entities(title)) else: self.number_results = 0
def get_movie_details(self): """Returns dictionary with movie details""" if not self.cursor: self.cursor = self.connection.cursor() self.cursor.execute( \ 'SELECT id, title, year, rating, stars, director, synop, \ cover, runtime, genre, notes, trailer, star5 \ FROM dvd;') currentrow = self.cursor.fetchone() if not currentrow: return None details = {} try: if currentrow[1]: details['title'] = currentrow[1] if currentrow[2]: details['year'] = currentrow[2] if currentrow[3]: details['classification'] = currentrow[3] if currentrow[4]: details['cast'] = currentrow[4] if currentrow[5]: details['director'] = currentrow[5] if currentrow[6]: details['plot'] = currentrow[6] if currentrow[7]: details['poster'] = currentrow[7] if currentrow[8]: details['runtime'] = gutils.digits_only(currentrow[8]) if currentrow[9]: genre = string.replace(currentrow[9], '~', ', ') if len(genre) > 2: details['genre'] = genre[2:] if currentrow[10]: details['notes'] = currentrow[10] if currentrow[11]: details['trailer'] = currentrow[11] if currentrow[12]: try: details['rating'] = 2 * int(currentrow[12]) except: pass except Exception, e: log.exception('') details = None
def get_movie_details(self): """Returns dictionary with movie details""" if not self.cursor: self.cursor = self.connection.cursor() self.cursor.execute( \ 'SELECT id, title, year, rating, stars, director, synop, \ cover, runtime, genre, notes, trailer, star5 \ FROM dvd;' ) currentrow = self.cursor.fetchone() if not currentrow: return None details = {} try: if currentrow[1]: details['title'] = currentrow[1] if currentrow[2]: details['year'] = currentrow[2] if currentrow[3]: details['classification'] = currentrow[3] if currentrow[4]: details['cast'] = currentrow[4] if currentrow[5]: details['director'] = currentrow[5] if currentrow[6]: details['plot'] = currentrow[6] if currentrow[7]: details['poster'] = currentrow[7] if currentrow[8]: details['runtime'] = gutils.digits_only(currentrow[8]) if currentrow[9]: genre = string.replace(currentrow[9], '~', ', ') if len(genre) > 2: details['genre'] = genre[2:] if currentrow[10]: details['notes'] = currentrow[10] if currentrow[11]: details['trailer'] = currentrow[11] if currentrow[12]: try: details['rating'] = 2 * int(currentrow[12]) except: pass except Exception, e: log.exception('') details = None
def add_person_db(self): name = self.widgets['person']['name'].get_text().decode('utf-8') if name: p = db.Person() try: p.name = self.widgets['person']['name'].get_text().decode('utf-8') p.email = self.widgets['person']['email'].get_text().decode('utf-8') p.phone = gutils.digits_only(self.widgets['person']['phone'].get_text().decode('utf-8')) except ValueError, e: gutils.warning(e.message) return False self.widgets['person']['window'].hide() self.db.session.add(p) try: self.db.session.commit() except Exception, e: log.info(str(e))
def get_searches(self): elements = string.split(self.page, '<a href="/filmes/') self.number_results = elements[-1] if len(elements[0]): for element in elements: id = gutils.digits_only(gutils.before(element, '"')) title = gutils.clean( re.sub( '</div>.*', '', string.replace( gutils.before(gutils.after(element, '>'), '</small>'), '<small>', ' / '))) if id and title and title[0] != '<': self.ids.append(id) self.titles.append(gutils.convert_entities(title)) else: self.number_results = 0
def add_person_db(self): name = self.widgets['person']['name'].get_text().decode('utf-8') if name: p = db.Person() try: p.name = self.widgets['person']['name'].get_text().decode('utf-8') p.email = self.widgets['person']['email'].get_text().decode('utf-8') p.phone = gutils.digits_only(self.widgets['person']['phone'].get_text().decode('utf-8')) except ValueError, e: gutils.warning(e.message) return False self.widgets['person']['window'].hide() self.db.session.add(p) try: self.db.session.commit() except Exception, e: self.db.session.rollback() log.info(str(e))
def add_person_db(self): name = self.widgets["person"]["name"].get_text().decode("utf-8") if name: p = db.Person() try: p.name = self.widgets["person"]["name"].get_text().decode("utf-8") p.email = self.widgets["person"]["email"].get_text().decode("utf-8") p.phone = gutils.digits_only(self.widgets["person"]["phone"].get_text().decode("utf-8")) except ValueError, e: gutils.warning(e.message) return False self.widgets["person"]["window"].hide() self.db.session.add(p) try: self.db.session.commit() except Exception, e: self.db.session.rollback() log.info(str(e))
def set_details(self, item=None):#{{{ if item is None: item = {} if item.has_key('movie_id') 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 item.has_key('o_title') and item['o_title']: w['o_title'].set_text(item['o_title']) else: w['o_title'].set_text('') if item.has_key('title') and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if item.has_key('number') and item['number']: w['number'].set_value(int(item['number'])) else: w['number'].set_value(int(gutils.find_next_available(self.db))) if item.has_key('title') and item['title']: w['title'].set_text(item['title']) if item.has_key('year') and item['year']: w['year'].set_value( gutils.digits_only(item['year'], 2100)) else: w['year'].set_value(0) if item.has_key('runtime') and item['runtime']: w['runtime'].set_value( gutils.digits_only(item['runtime'])) else: w['runtime'].set_value(0) if item.has_key('country') and item['country']: w['country'].set_text(item['country']) else: w['country'].set_text('') if item.has_key('classification') and item['classification']: w['classification'].set_text(item['classification']) else: w['classification'].set_text('') if item.has_key('studio') and item['studio']: w['studio'].set_text(item['studio']) else: w['studio'].set_text('') if item.has_key('o_site') and item['o_site']: w['o_site'].set_text(item['o_site']) else: w['o_site'].set_text('') if item.has_key('director') and item['director']: w['director'].set_text(item['director']) else: w['director'].set_text('') if item.has_key('site') and item['site']: w['site'].set_text(item['site']) else: w['site'].set_text('') if item.has_key('trailer') and item['trailer']: w['trailer'].set_text(item['trailer']) else: w['trailer'].set_text('') if item.has_key('title') and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if item.has_key('genre') and item['genre']: w['genre'].set_text(item['genre']) else: w['genre'].set_text('') if item.has_key('color') 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 item.has_key('layers') 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 item.has_key('region') 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 item.has_key('cond') 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 item.has_key('media_num') and item['media_num']: w['discs'].set_value( gutils.digits_only(item['media_num'])) else: w['discs'].set_value(1) if item.has_key('rating') and item['rating']: w['rating_slider'].set_value( gutils.digits_only(item['rating'], 10) ) else: w['rating_slider'].set_value(0) if item.has_key('seen') and item['seen'] is True: w['seen'].set_active(True) else: w['seen'].set_active(False) if item.has_key('cast') and item['cast']: cast_buffer.set_text(item['cast']) else: cast_buffer.set_text('') if item.has_key('notes') and item['notes']: notes_buffer.set_text(item['notes']) else: notes_buffer.set_text('') if item.has_key('plot') and item['plot']: plot_buffer.set_text(item['plot']) else: plot_buffer.set_text('') pos = 0 if item.has_key('medium_id') 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 item.has_key('vcodec_id') 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 item.has_key('volume_id') 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 item.has_key('collection_id') 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['volume'].set_active(0) # tags for tag in self.am_tags: self.am_tags[tag].set_active(False) if item.has_key('tags'): 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 item.has_key('languages') and len(item['languages'])>0: for i in item['languages']: self.create_language_row(i) # poster if item.has_key('image') and item['image']: w['image'].set_text(item['image']) image_path = os.path.join(self.locations['posters'], "m_%s.jpg" % item['image']) else: w['image'].set_text('') image_path = os.path.join(self.locations['images'], 'default.png') if not os.path.isfile(image_path): image_path = os.path.join(self.locations['images'], 'default.png') w['picture'].set_from_file(image_path) w['notebook'].set_current_page(0) w['source'].set_active(self.d_plugin) w['o_title'].grab_focus()
def get_movie_details(self): """Returns dictionary with movie details""" if not self.cursor: self.cursor = self.connection.cursor() self.cursor.execute( \ 'SELECT MovieID, barcode, comments, description, length, mediacount, MediaTypeName, \ mpaa, movies.Name, originaltitle, rating, seen, studio, url, year, Trailer, \ MediaLocation.Name \ FROM (movies \ LEFT OUTER JOIN MediaType ON movies.MediaTypeID=MediaType.MediaTypeID) \ LEFT OUTER JOIN MediaLocation ON movies.medialocationID=MediaLocation.MediaLocationID;' ) currentrow = self.cursor.fetchone() if not currentrow: return None details = {} try: movieID = currentrow[0] if currentrow[1]: details['barcode'] = currentrow[1] if currentrow[2]: details['notes'] = currentrow[2] if currentrow[3]: details['plot'] = currentrow[3] if currentrow[4]: details['runtime'] = gutils.digits_only(currentrow[4]) if currentrow[5]: details['media_num'] = currentrow[5] if currentrow[6]: details['medium_id'] = currentrow[6] if currentrow[7]: details['classification'] = currentrow[7] if currentrow[8]: details['title'] = currentrow[8] if currentrow[9]: details['o_title'] = currentrow[9] if currentrow[10]: details['rating'] = round(currentrow[10] / 10.0, 0) if currentrow[11]: details['seen'] = currentrow[11] if currentrow[12]: details['studio'] = currentrow[12] if currentrow[13]: details['site'] = currentrow[13] if currentrow[14]: details['year'] = currentrow[14] if currentrow[15]: details['trailer'] = currentrow[15] if currentrow[16]: details['volume_id'] = currentrow[16] # loading other details curs = self.connection.cursor() curs.execute('SELECT Actors.Name, ActorsLink.Role \ FROM Actors INNER JOIN ActorsLink ON Actors.ActorID=ActorsLink.ActorID \ WHERE ActorsLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: if currentrow[1]: cast = currentrow[0] + _(' as ') + currentrow[1] else: cast = currentrow[0] currentrow = curs.fetchone() while currentrow: if currentrow[1]: cast = cast + '\n' + currentrow[0] + _( ' as ') + currentrow[1] else: cast = cast + '\n' + currentrow[0] currentrow = curs.fetchone() details['cast'] = cast curs.execute('SELECT Countries.Name \ FROM Countries INNER JOIN CountryLink ON Countries.CountryID=CountryLink.CountryID \ WHERE CountryLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: country = currentrow[0] currentrow = curs.fetchone() while currentrow: country = country + ', ' + currentrow[0] currentrow = curs.fetchone() details['country'] = country curs.execute('SELECT Actors.Name \ FROM Actors INNER JOIN DirectorLink ON Actors.ActorID=DirectorLink.ActorID \ WHERE DirectorLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: director = currentrow[0] currentrow = curs.fetchone() while currentrow: director = director + ', ' + currentrow[0] currentrow = curs.fetchone() details['director'] = director curs.execute('SELECT Genres.Name \ FROM Genres INNER JOIN GenresLink ON Genres.GenreID=GenresLink.GenreID \ WHERE GenresLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: genre = currentrow[0] currentrow = curs.fetchone() while currentrow: genre = genre + ', ' + currentrow[0] currentrow = curs.fetchone() details['genre'] = genre curs.execute('SELECT images.image \ FROM images \ WHERE cover=-1 AND images.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: details['poster'] = currentrow[0] curs.close() except Exception, e: log.exception('') details = None
def get_runtime(self): # Find the film's running time self.runtime = gutils.trim(self.page, ">Durata</font>", "</tr>") self.runtime = gutils.digits_only(gutils.clean(self.runtime))
def get_year(self): # Find the film's year self.year = gutils.trim(self.page, ">Anno</font>", "</tr>") self.year = gutils.digits_only(gutils.clean(self.year))
def get_movie_details(self): """Returns dictionary with movie details""" if not self.cursor: self.cursor = self.connection.cursor() self.cursor.execute( \ 'SELECT MovieID, barcode, comments, description, length, mediacount, MediaTypeName, \ mpaa, Name, originaltitle, rating, seen, studio, url, year, Trailer \ FROM movies LEFT OUTER JOIN MediaType ON movies.MediaTypeID=MediaType.MediaTypeID;') currentrow = self.cursor.fetchone() if not currentrow: return None details = {} try: movieID = currentrow[0] if currentrow[1]: details['barcode'] = currentrow[1] if currentrow[2]: details['notes'] = currentrow[2] if currentrow[3]: details['plot'] = currentrow[3] if currentrow[4]: details['runtime'] = gutils.digits_only(currentrow[4]) if currentrow[5]: details['media_num'] = currentrow[5] if currentrow[6]: details['medium_id'] = currentrow[6] if currentrow[7]: details['classification'] = currentrow[7] if currentrow[8]: details['title'] = currentrow[8] if currentrow[9]: details['o_title'] = currentrow[9] if currentrow[10]: details['rating'] = round(currentrow[10] / 10.0, 0) if currentrow[11]: details['seen'] = currentrow[11] if currentrow[12]: details['studio'] = currentrow[12] if currentrow[13]: details['site'] = currentrow[13] if currentrow[14]: details['year'] = currentrow[14] if currentrow[15]: details['trailer'] = currentrow[15] # loading other details curs = self.connection.cursor() curs.execute('SELECT Actors.Name, ActorsLink.Role \ FROM Actors INNER JOIN ActorsLink ON Actors.ActorID=ActorsLink.ActorID \ WHERE ActorsLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: if currentrow[1]: cast = currentrow[0] + _(' as ') + currentrow[1] else: cast = currentrow[0] currentrow = curs.fetchone() while currentrow: if currentrow[1]: cast = cast + '\n' + currentrow[0] + _(' as ') + currentrow[1] else: cast = cast + '\n' + currentrow[0] currentrow = curs.fetchone() details['cast'] = cast curs.execute('SELECT Countries.Name \ FROM Countries INNER JOIN CountryLink ON Countries.CountryID=CountryLink.CountryID \ WHERE CountryLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: country = currentrow[0] currentrow = curs.fetchone() while currentrow: country = country + ', ' + currentrow[0] currentrow = curs.fetchone() details['country'] = country curs.execute('SELECT Actors.Name \ FROM Actors INNER JOIN DirectorLink ON Actors.ActorID=DirectorLink.ActorID \ WHERE DirectorLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: director = currentrow[0] currentrow = curs.fetchone() while currentrow: director = director + ', ' + currentrow[0] currentrow = curs.fetchone() details['director'] = director curs.execute('SELECT Genres.Name \ FROM Genres INNER JOIN GenresLink ON Genres.GenreID=GenresLink.GenreID \ WHERE GenresLink.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: genre = currentrow[0] currentrow = curs.fetchone() while currentrow: genre = genre + ', ' + currentrow[0] currentrow = curs.fetchone() details['genre'] = genre curs.execute('SELECT images.image \ FROM images \ WHERE cover=-1 AND images.MovieID=' + str(movieID)) currentrow = curs.fetchone() if currentrow: details['poster'] = currentrow[0] curs.close() except Exception, e: log.exception('') details = None
def get_details(self): #{{{ w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() t_movies = { 'cameraman': w['cameraman'].get_text().decode('utf-8'), 'classification': w['classification'].get_text().decode('utf-8'), 'barcode': unicode(gutils.digits_only(w['barcode'].get_text().decode('utf-8'))), 'color': w['color'].get_active(), 'cond': w['condition'].get_active(), 'country': w['country'].get_text().decode('utf-8'), 'director': w['director'].get_text().decode('utf-8'), 'genre': w['genre'].get_text().decode('utf-8'), 'image': w['image'].get_text().decode('utf-8'), 'layers': w['layers'].get_active(), 'media_num': w['discs'].get_value(), 'number': w['number'].get_value(), 'o_site': w['o_site'].get_text().decode('utf-8'), 'o_title': w['o_title'].get_text().decode('utf-8'), 'rating': w['rating_slider'].get_value(), 'region': w['region'].get_active(), 'resolution': w['resolution'].get_text().strip().decode('utf-8'), 'runtime': w['runtime'].get_text().decode('utf-8'), 'screenplay': w['screenplay'].get_text().decode('utf-8'), 'site': w['site'].get_text().decode('utf-8'), 'studio': w['studio'].get_text().decode('utf-8'), 'title': w['title'].get_text().decode('utf-8'), 'trailer': w['trailer'].get_text().decode('utf-8'), 'year': w['year'].get_value(), 'collection_id': w['collection'].get_active(), 'medium_id': w['media'].get_active(), 'volume_id': w['volume'].get_active(), 'vcodec_id': w['vcodec'].get_active(), 'cast': cast_buffer.get_text(cast_buffer.get_start_iter(), cast_buffer.get_end_iter()).decode('utf-8'), 'notes': notes_buffer.get_text(notes_buffer.get_start_iter(), notes_buffer.get_end_iter()).decode('utf-8'), 'plot': plot_buffer.get_text(plot_buffer.get_start_iter(), plot_buffer.get_end_iter()).decode('utf-8'), 'created': None, 'updated': None } if self._am_movie_id is not None: t_movies['movie_id'] = self._am_movie_id if t_movies['collection_id'] > 0: t_movies['collection_id'] = self.collection_combo_ids[t_movies['collection_id']] else: t_movies['collection_id'] = None if t_movies['volume_id'] > 0: t_movies['volume_id'] = self.volume_combo_ids[t_movies['volume_id']] else: t_movies['volume_id'] = None if t_movies['medium_id'] > 0: t_movies['medium_id'] = self.media_ids[t_movies['medium_id']] else: t_movies['medium_id'] = None if t_movies['vcodec_id'] > 0: t_movies['vcodec_id'] = self.vcodecs_ids[t_movies['vcodec_id']] else: t_movies['vcodec_id'] = None if t_movies['barcode'] == '0': t_movies['barcode'] = None if w['seen'].get_active(): t_movies['seen'] = True else: t_movies['seen'] = False if t_movies['year'] < 1900: t_movies['year'] = None def get_id(model, text): for i in model: if i[1] == text: return i[0] return None # languages t_movies['languages'] = set() for row in self.lang['model']: lang_id = get_id(self.lang['lang'], row[0]) lang_type = get_id(self.lang['type'], row[1]) acodec = get_id(self.lang['acodec'], row[2]) achannel = get_id(self.lang['achannel'], row[3]) subformat = get_id(self.lang['subformat'], row[4]) t_movies['languages'].add((lang_id, lang_type, acodec, achannel, subformat)) # tags t_movies['tags'] = {} for i in self.tags_ids: if self.am_tags[i].get_active() == True: t_movies['tags'][self.tags_ids[i]] = 1 validate_details(t_movies) return t_movies #}}}
def get_details(self): #{{{ w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() t_movies = { 'cameraman': w['cameraman'].get_text().decode('utf-8'), 'classification': w['classification'].get_text().decode('utf-8'), 'barcode': unicode(gutils.digits_only(w['barcode'].get_text().decode('utf-8'))), 'color': w['color'].get_active(), 'cond': w['condition'].get_active(), 'country': w['country'].get_text().decode('utf-8'), 'director': w['director'].get_text().decode('utf-8'), 'genre': w['genre'].get_text().decode('utf-8'), 'image': w['image'].get_text().decode('utf-8'), 'layers': w['layers'].get_active(), 'media_num': w['discs'].get_value(), 'number': w['number'].get_value(), 'o_site': w['o_site'].get_text().decode('utf-8'), 'o_title': w['o_title'].get_text().decode('utf-8'), 'rating': w['rating_slider'].get_value(), 'region': w['region'].get_active(), 'resolution': w['resolution'].get_child().get_text().strip().decode('utf-8'), 'runtime': w['runtime'].get_text().decode('utf-8'), 'screenplay': w['screenplay'].get_text().decode('utf-8'), 'site': w['site'].get_text().decode('utf-8'), 'studio': w['studio'].get_text().decode('utf-8'), 'title': w['title'].get_text().decode('utf-8'), 'trailer': w['trailer'].get_text().decode('utf-8'), 'year': w['year'].get_value(), 'collection_id': w['collection'].get_active(), 'medium_id': w['media'].get_active(), 'volume_id': w['volume'].get_active(), 'vcodec_id': w['vcodec'].get_active(), 'cast': cast_buffer.get_text(cast_buffer.get_start_iter(), cast_buffer.get_end_iter()).decode('utf-8'), 'notes': notes_buffer.get_text(notes_buffer.get_start_iter(), notes_buffer.get_end_iter()).decode('utf-8'), 'plot': plot_buffer.get_text(plot_buffer.get_start_iter(), plot_buffer.get_end_iter()).decode('utf-8'), 'created': None, 'updated': None } if self._am_movie_id is not None: t_movies['movie_id'] = self._am_movie_id if t_movies['collection_id'] > 0: t_movies['collection_id'] = self.collection_combo_ids[ t_movies['collection_id']] else: t_movies['collection_id'] = None if t_movies['volume_id'] > 0: t_movies['volume_id'] = self.volume_combo_ids[t_movies['volume_id']] else: t_movies['volume_id'] = None if t_movies['medium_id'] > 0: t_movies['medium_id'] = self.media_ids[t_movies['medium_id']] else: t_movies['medium_id'] = None if t_movies['vcodec_id'] > 0: t_movies['vcodec_id'] = self.vcodecs_ids[t_movies['vcodec_id']] else: t_movies['vcodec_id'] = None if t_movies['barcode'] == '0': t_movies['barcode'] = None if w['seen'].get_active(): t_movies['seen'] = True else: t_movies['seen'] = False if t_movies['year'] < 1900: t_movies['year'] = None def get_id(model, text): for i in model: if i[1] == text: return i[0] return None # languages t_movies['languages'] = set() # isn't the best but it works. without it the current selection of a language field is lost w['lang_treeview'].child_focus(gtk.DIR_TAB_FORWARD) for row in self.lang['model']: lang_id = get_id(self.lang['lang'], row[0]) lang_type = get_id(self.lang['type'], row[1]) acodec = get_id(self.lang['acodec'], row[2]) achannel = get_id(self.lang['achannel'], row[3]) subformat = get_id(self.lang['subformat'], row[4]) t_movies['languages'].add( (lang_id, lang_type, acodec, achannel, subformat)) # tags t_movies['tags'] = {} for i in self.tags_ids: if self.am_tags[i].get_active() == True: t_movies['tags'][self.tags_ids[i]] = 1 validate_details(t_movies) return t_movies #}}}
def process_movie_value(self, document, dvdelement, key, value): if key == 'movies_number': dvdelement.setAttribute('id', value) elif key == 'movies_loaned': pass elif key == 'movies_seen': dvdelement.setAttribute('seen', value) elif key == 'movies_rating': dvdelement.setAttribute('rating', value) elif key == 'movies_color': # SmallInteger pass elif key == 'movies_cond': # SmallInteger pass elif key == 'movies_layers': # SmallInteger pass elif key == 'movies_media_num': # SmallInteger dvdelement.setAttribute('number', value) elif key == 'movies_runtime': # Integer dvdelement.setAttribute('time', value) elif key == 'movies_year': # year dvdelement.setAttribute('date', value) elif key == 'movies_o_title': # VARCHAR dvdelement.setAttribute('original', value) elif key == 'movies_title': # VARCHAR dvdelement.setAttribute('title', value) elif key == 'movies_director': # VARCHAR dvdelement.setAttribute('director', value) elif key == 'movies_o_site': # VARCHAR pass elif key == 'movies_site': # VARCHAR dvdelement.setAttribute('webPage', value) elif key == 'movies_trailer': # VARCHAR if len(value.strip()) > 0: trailersplit = value.split('file://') if len(trailersplit) > 1: if gutils.is_windows_system(): dvdelement.setAttribute('trailer', trailersplit[1].lstrip('/')) else: dvdelement.setAttribute('trailer', trailersplit[1]) else: dvdelement.setAttribute('trailer', trailersplit[0]) elif key == 'movies_country': # VARCHAR dvdelement.setAttribute('country', value) elif key == 'movies_genre': # VARCHAR dvdelement.setAttribute('genre', value.replace('\n', '')) elif key == 'movies_region': # SmallInteger pass elif key == 'movies_studio': # VARCHAR pass elif key == 'movies_classification': # VARCHAR dvdelement.setAttribute('age', str(gutils.digits_only(value))) elif key == 'movies_cast': # VARCHAR if len(value.strip()) > 0: actors = value.split('\n') actorsstring = '' delim = '' for actor in actors: actorsplit = actor.split(_(' as ')) actornames = actorsplit[0] role = '' if len(actorsplit) > 1: role = actorsplit[1] actorsstring += delim + actornames.strip() + ' (' + role.strip() + ')' delim = ', ' dvdelement.setAttribute('actors', actorsstring) elif key == 'movies_plot': # VARCHAR elem = document.createElement('synopsis') dvdelement.appendChild(elem) t = document.createTextNode(value) elem.appendChild(t) elif key == 'movies_notes': # VARCHAR elem = document.createElement('comment') dvdelement.appendChild(elem) t = document.createTextNode(value) elem.appendChild(t) elif key == 'volumes_name': # VARCHAR dvdelement.setAttribute('place', value) elif key == 'collections_name': # VARCHAR dvdelement.setAttribute('serie', value) elif key == 'vcodecs_name': # VARCHAR dvdelement.setAttribute('video', value) elif key == 'media_name': # VARCHAR dvdelement.setAttribute('format', value)
def show_preferences(self): w = self.widgets['preferences'] # number if self.config.get('number', True, section='mainlist') == False: w['view_number'].set_active(False) else: w['view_number'].set_active(True) # image if self.config.get('image', True, section='mainlist') == False: w['view_image'].set_active(False) else: w['view_image'].set_active(True) # original title if self.config.get('otitle', True, section='mainlist') == False: w['view_o_title'].set_active(False) else: w['view_o_title'].set_active(True) # title if self.config.get('title', True, section='mainlist') == False: w['view_title'].set_active(False) else: w['view_title'].set_active(True) # director if self.config.get('director', True, 'mainlist') == False: w['view_director'].set_active(False) else: w['view_director'].set_active(True) # genre if self.config.get('genre', True, 'mainlist') == False: w['view_genre'].set_active(False) else: w['view_genre'].set_active(True) # seen if self.config.get('seen', True, 'mainlist') == False: w['view_seen'].set_active(False) else: w['view_seen'].set_active(True) # year if self.config.get('year', True, 'mainlist') == False: w['view_year'].set_active(False) else: w['view_year'].set_active(True) # runtime if self.config.get('runtime', True, 'mainlist') == False: w['view_runtime'].set_active(False) else: w['view_runtime'].set_active(True) # rating if self.config.get('rating', True, 'mainlist') == False: w['view_rating'].set_active(False) else: w['view_rating'].set_active(True) # email reminder if self.config.get('use_auth', False, section='mail') == False: w['mail_use_auth'].set_active(False) else: w['mail_use_auth'].set_active(True) if self.config.get('mail_use_tls', False, section='mail') == False: w['mail_use_tls'].set_active(False) else: w['mail_use_tls'].set_active(True) w['mail_smtp_server'].set_text(self.config.get('smtp_server', 'localhost', section='mail')) w['mail_smtp_port'].set_text(self.config.get('mail_smtp_port', '25', section='mail')) w['mail_username'].set_text(self.config.get('username', '', section='mail')) w['mail_password'].set_text(self.config.get('password', '', section='mail')) w['mail_email'].set_text(self.config.get('email', 'griffith@localhost', section='mail')) # pdf reader w['epdf_reader'].set_text(self.pdf_reader) # pdf font if self.config.get('font'): w['font'].set_filename(self.config.get('font')) # defaults (for static data only) w['condition'].set_active( gutils.digits_only(self.config.get('condition', 0, section='defaults'), 5) ) w['region'].set_active( gutils.digits_only(self.config.get('region', 0, section='defaults'), 8) ) w['layers'].set_active( gutils.digits_only(self.config.get('layers', 0, section='defaults'), 4) ) w['color'].set_active( gutils.digits_only(self.config.get('color', 0, section='defaults'), 3 )) tmp = self.config.get('media', 0, section='defaults') if tmp is not None and int(tmp) in self.media_ids: if int(self.config.get('media', 0, section='defaults')) > 0: w['media'].set_active( gutils.findKey(int(self.config.get('media', 0, section='defaults')), self.media_ids) ) else: w['media'].set_active(0) tmp = self.config.get('vcodec', 0, section='defaults') if tmp is not None and int(tmp) in self.vcodecs_ids: if int(self.config.get('vcodec', 0, section='defaults')) > 0: w['vcodec'].set_active( int(gutils.findKey(int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids)) ) else: w['vcodec'].set_active(0) # search for: w['s_classification'].set_active(bool(self.config.get('s_classification', True, section='add'))) w['s_country'].set_active(bool(self.config.get('s_country', True, section='add'))) w['s_director'].set_active(bool(self.config.get('s_director', True, section='add'))) w['s_genre'].set_active(bool(self.config.get('s_genre', True, section='add'))) w['s_image'].set_active(bool(self.config.get('s_image', True, section='add'))) w['s_notes'].set_active(bool(self.config.get('s_notes', True, section='add'))) w['s_o_site'].set_active(bool(self.config.get('s_o_site', True, section='add'))) w['s_o_title'].set_active(bool(self.config.get('s_o_title', True, section='add'))) w['s_plot'].set_active(bool(self.config.get('s_plot', True, section='add'))) w['s_rating'].set_active(bool(self.config.get('s_rating', True, section='add'))) w['s_runtime'].set_active(bool(self.config.get('s_runtime', True, section='add'))) w['s_site'].set_active(bool(self.config.get('s_site', True, section='add'))) w['s_studio'].set_active(bool(self.config.get('s_studio', True, section='add'))) w['s_title'].set_active(bool(self.config.get('s_title', True, section='add'))) w['s_trailer'].set_active(bool(self.config.get('s_trailer', True, section='add'))) w['s_cast'].set_active(bool(self.config.get('s_cast', True, section='add'))) w['s_year'].set_active(bool(self.config.get('s_year', True, section='add'))) if self.config.get('sortby', section='mainlist'): tmp = self.sort_criteria.index(self.config.get('sortby', section='mainlist')) w['sortby'].set_active(tmp) w['sortby_reverse'].set_active(bool(self.config.get('sortby_reverse', False, section='mainlist'))) w['s_limit'].set_value(gutils.digits_only(self.config.get('limit', 0, section='mainlist'))) plugins = gutils.read_plugins('PluginMovie', \ self.locations['movie_plugins']) plugins.sort() mcounter = 0 default_movie_plugin = self.config.get('default_movie_plugin') for p in plugins: plugin_module = os.path.basename(p).replace('.py','') plugin_name = plugin_module.replace('PluginMovie','') if plugin_name == default_movie_plugin: w['default_plugin'].set_active(mcounter) self.d_plugin = mcounter mcounter = mcounter + 1 # rating image try: rimage = int(self.config.get('rating_image', 0)) except: rimage = 0 w['rating_image'].set_active(rimage) # spellchecker if self.config.get('gtkspell', False, section='spell') == False: w['spellchecker'].set_active(False) else: w['spellchecker'].set_active(True) self.on_cb_spellchecker_pref_toggled(w['spellchecker']) if self.config.get('notes', True, section='spell') == False: w['spell_notes'].set_active(False) else: w['spell_notes'].set_active(True) if self.config.get('plot', True, section='spell') == False: w['spell_plot'].set_active(False) else: w['spell_plot'].set_active(True) w['spell_lang'].set_text(str(self.config.get('lang', 'en', section='spell'))) w['amazon_locale'].set_active(int(self.config.get('amazon_locale', 0, section='add'))) w['window'].show()
def process_movie_value(self, document, dvdelement, key, value): if key == 'movies_number': dvdelement.setAttribute('id', value) elif key == 'movies_loaned': pass elif key == 'movies_seen': dvdelement.setAttribute('seen', value) elif key == 'movies_rating': dvdelement.setAttribute('rating', value) elif key == 'movies_color': # SmallInteger pass elif key == 'movies_cond': # SmallInteger pass elif key == 'movies_layers': # SmallInteger pass elif key == 'movies_media_num': # SmallInteger dvdelement.setAttribute('number', value) elif key == 'movies_runtime': # Integer dvdelement.setAttribute('time', value) elif key == 'movies_year': # year dvdelement.setAttribute('date', value) elif key == 'movies_o_title': # VARCHAR dvdelement.setAttribute('original', value) elif key == 'movies_title': # VARCHAR dvdelement.setAttribute('title', value) elif key == 'movies_director': # VARCHAR dvdelement.setAttribute('director', value) elif key == 'movies_o_site': # VARCHAR pass elif key == 'movies_site': # VARCHAR dvdelement.setAttribute('webPage', value) elif key == 'movies_trailer': # VARCHAR if len(value.strip()) > 0: trailersplit = value.split('file://') if len(trailersplit) > 1: if gutils.is_windows_system(): dvdelement.setAttribute('trailer', trailersplit[1].lstrip('/')) else: dvdelement.setAttribute('trailer', trailersplit[1]) else: dvdelement.setAttribute('trailer', trailersplit[0]) elif key == 'movies_country': # VARCHAR dvdelement.setAttribute('country', value) elif key == 'movies_genre': # VARCHAR dvdelement.setAttribute('genre', value.replace('\n', '')) elif key == 'movies_region': # SmallInteger pass elif key == 'movies_studio': # VARCHAR pass elif key == 'movies_classification': # VARCHAR dvdelement.setAttribute('age', str(gutils.digits_only(value))) elif key == 'movies_cast': # VARCHAR if len(value.strip()) > 0: actors = value.split('\n') actorsstring = '' delim = '' for actor in actors: actorsplit = actor.split(_(' as ')) actornames = actorsplit[0] role = '' if len(actorsplit) > 1: role = actorsplit[1] actorsstring += delim + actornames.strip( ) + ' (' + role.strip() + ')' delim = ', ' dvdelement.setAttribute('actors', actorsstring) elif key == 'movies_plot': # VARCHAR elem = document.createElement('synopsis') dvdelement.appendChild(elem) t = document.createTextNode(value) elem.appendChild(t) elif key == 'movies_notes': # VARCHAR elem = document.createElement('comment') dvdelement.appendChild(elem) t = document.createTextNode(value) elem.appendChild(t) elif key == 'volumes_name': # VARCHAR dvdelement.setAttribute('place', value) elif key == 'collections_name': # VARCHAR dvdelement.setAttribute('serie', value) elif key == 'vcodecs_name': # VARCHAR dvdelement.setAttribute('video', value) elif key == 'media_name': # VARCHAR dvdelement.setAttribute('format', value)
def show_preferences(self, page=None): w = self.widgets['preferences'] # number if self.config.get('number', True, section='mainlist') == False: w['view_number'].set_active(False) else: w['view_number'].set_active(True) # image if self.config.get('image', True, section='mainlist') == False: w['view_image'].set_active(False) else: w['view_image'].set_active(True) # original title if self.config.get('otitle', True, section='mainlist') == False: w['view_o_title'].set_active(False) else: w['view_o_title'].set_active(True) # title if self.config.get('title', True, section='mainlist') == False: w['view_title'].set_active(False) else: w['view_title'].set_active(True) # director if self.config.get('director', True, 'mainlist') == False: w['view_director'].set_active(False) else: w['view_director'].set_active(True) # genre if self.config.get('genre', True, 'mainlist') == False: w['view_genre'].set_active(False) else: w['view_genre'].set_active(True) # seen if self.config.get('seen', True, 'mainlist') == False: w['view_seen'].set_active(False) else: w['view_seen'].set_active(True) # year if self.config.get('year', True, 'mainlist') == False: w['view_year'].set_active(False) else: w['view_year'].set_active(True) # runtime if self.config.get('runtime', True, 'mainlist') == False: w['view_runtime'].set_active(False) else: w['view_runtime'].set_active(True) # rating if self.config.get('rating', True, 'mainlist') == False: w['view_rating'].set_active(False) else: w['view_rating'].set_active(True) # created if self.config.get('created', True, 'mainlist') == False: w['view_created'].set_active(False) else: w['view_created'].set_active(True) # updated if self.config.get('updated', True, 'mainlist') == False: w['view_updated'].set_active(False) else: w['view_updated'].set_active(True) # email reminder if self.config.get('use_auth', False, section='mail') == False: w['mail_use_auth'].set_active(False) else: w['mail_use_auth'].set_active(True) if self.config.get('mail_use_tls', False, section='mail') == False: w['mail_use_tls'].set_active(False) else: w['mail_use_tls'].set_active(True) w['mail_smtp_server'].set_text( self.config.get('smtp_server', 'localhost', section='mail')) w['mail_smtp_port'].set_text( self.config.get('mail_smtp_port', '25', section='mail')) w['mail_username'].set_text(self.config.get('username', '', section='mail')) w['mail_password'].set_text(self.config.get('password', '', section='mail')) w['mail_email'].set_text( self.config.get('email', 'griffith@localhost', section='mail')) # pdf reader w['epdf_reader'].set_text(self.pdf_reader) # pdf font if self.config.get('font'): w['font'].set_filename(self.config.get('font')) if self.config.get('font_size'): try: w['font_size'].set_value(float(self.config.get('font_size'))) except: w['font_size'].set_value(18.0) # pdf elements pdf_elements = self.config.get('pdf_elements', 'image,director,genre,cast') for pdf_element in pdf_elements.split(','): if 'pdf_' + pdf_element.strip() in w: w['pdf_' + pdf_element.strip()].set_active(True) # defaults (for static data only) w['condition'].set_active( gutils.digits_only(self.config.get('condition', 0, section='defaults'), 5)) w['region'].set_active( gutils.digits_only(self.config.get('region', 0, section='defaults'), 8)) w['layers'].set_active( gutils.digits_only(self.config.get('layers', 0, section='defaults'), 4)) w['color'].set_active( gutils.digits_only(self.config.get('color', 0, section='defaults'), 3)) tmp = self.config.get('media', 0, section='defaults') if tmp is not None and int(tmp) in self.media_ids: if int(self.config.get('media', 0, section='defaults')) > 0: w['media'].set_active( gutils.findKey( int(self.config.get('media', 0, section='defaults')), self.media_ids)) else: w['media'].set_active(0) tmp = self.config.get('vcodec', 0, section='defaults') if tmp is not None and int(tmp) in self.vcodecs_ids: if int(self.config.get('vcodec', 0, section='defaults')) > 0: w['vcodec'].set_active( int( gutils.findKey( int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids))) else: w['vcodec'].set_active(0) w['seen'].set_active( bool(self.config.get('seen', True, section='defaults'))) # search for: w['s_classification'].set_active( bool(self.config.get('s_classification', True, section='add'))) w['s_country'].set_active( bool(self.config.get('s_country', True, section='add'))) w['s_director'].set_active( bool(self.config.get('s_director', True, section='add'))) w['s_genre'].set_active( bool(self.config.get('s_genre', True, section='add'))) w['s_image'].set_active( bool(self.config.get('s_image', True, section='add'))) w['s_notes'].set_active( bool(self.config.get('s_notes', True, section='add'))) w['s_o_site'].set_active( bool(self.config.get('s_o_site', True, section='add'))) w['s_o_title'].set_active( bool(self.config.get('s_o_title', True, section='add'))) w['s_plot'].set_active(bool(self.config.get('s_plot', True, section='add'))) w['s_rating'].set_active( bool(self.config.get('s_rating', True, section='add'))) w['s_runtime'].set_active( bool(self.config.get('s_runtime', True, section='add'))) w['s_site'].set_active(bool(self.config.get('s_site', True, section='add'))) w['s_studio'].set_active( bool(self.config.get('s_studio', True, section='add'))) w['s_title'].set_active( bool(self.config.get('s_title', True, section='add'))) w['s_trailer'].set_active( bool(self.config.get('s_trailer', True, section='add'))) w['s_cast'].set_active(bool(self.config.get('s_cast', True, section='add'))) w['s_year'].set_active(bool(self.config.get('s_year', True, section='add'))) w['s_screenplay'].set_active( bool(self.config.get('s_screenplay', True, section='add'))) w['s_cameraman'].set_active( bool(self.config.get('s_cameraman', True, section='add'))) w['s_resolution'].set_active( bool(self.config.get('s_resolution', True, section='add'))) w['s_barcode'].set_active( bool(self.config.get('s_barcode', True, section='add'))) if self.config.get('sortby', section='mainlist'): tmp = self.sort_criteria.index( self.config.get('sortby', section='mainlist')) w['sortby'].set_active(tmp) w['sortby_reverse'].set_active( bool(self.config.get('sortby_reverse', False, section='mainlist'))) w['s_limit'].set_value( gutils.digits_only(self.config.get('limit', 0, section='mainlist'))) plugins = gutils.read_plugins('PluginMovie', \ self.locations['movie_plugins']) plugins.sort() mcounter = 0 default_movie_plugin = self.config.get('default_movie_plugin') for p in plugins: plugin_module = os.path.basename(p).replace('.py', '') plugin_name = plugin_module.replace('PluginMovie', '') if plugin_name == default_movie_plugin: w['default_plugin'].set_active(mcounter) mcounter = mcounter + 1 # rating image try: rimage = int(self.config.get('rating_image', 0)) except: rimage = 0 w['rating_image'].set_active(rimage) # spellchecker if self.config.get('gtkspell', False, section='spell') == False: w['spellchecker'].set_active(False) else: w['spellchecker'].set_active(True) self.on_cb_spellchecker_pref_toggled(w['spellchecker']) if self.config.get('notes', True, section='spell') == False: w['spell_notes'].set_active(False) else: w['spell_notes'].set_active(True) if self.config.get('plot', True, section='spell') == False: w['spell_plot'].set_active(False) else: w['spell_plot'].set_active(True) w['spell_lang'].set_text( str(self.config.get('lang', 'en', section='spell'))) if page is not None: w['notebook'].set_current_page(page) w['window'].show()
except Exception, e: log.error(e) continue tag_mapper[i[0]] = o.tag_id # movies movie_mapper = {} old_cursor.execute(""" SELECT id, volume_id, collection_id, original_title, title, director, number, image, plot, country, year, runtime, classification, genre, studio, site, imdb, actors, trailer, rating, loaned, media, num_media, obs, seen, region, condition, color, layers FROM movies ORDER BY number;""") for i in old_cursor.fetchall(): o = db.Movie() o.number = digits_only(i[6]) if i[1] in volume_mapper: o.volume_id = volume_mapper[i[1]] if i[2] in collection_mapper: o.collection_id = collection_mapper[i[2]] o.o_title = i[3][:255] o.title = i[4][:255] o.director = i[5][:255] o.image = i[7][:128] o.plot = i[8] o.country = i[9][:128] o.year = digits_only(i[10]) o.runtime = digits_only(i[11]) o.classification = i[12][:128] o.genre = i[13][:128] o.studio = i[14][:128]
else: o = new_db.Tag(name=i[1]) o.save(); o.flush() tag_mapper[i[0]] = o.tag_id # movies movie_mapper = {} old_cursor.execute(""" SELECT id, volume_id, collection_id, original_title, title, director, number, image, plot, country, year, runtime, classification, genre, studio, site, imdb, actors, trailer, rating, loaned, media, num_media, obs, seen, region, condition, color, layers FROM movies ORDER BY number;""") for i in old_cursor.fetchall(): o = new_db.Movie() o.number = digits_only(i[6]) o.volume_id = volume_mapper[i[1]] o.collection_id = collection_mapper[i[2]] o.o_title = i[3][:255] o.title = i[4][:255] o.director = i[5][:255] o.image = i[7][:128] o.plot = i[8] o.country = i[9][:128] o.year = digits_only(i[10]) o.runtime = digits_only(i[11]) o.classification = i[12][:128] o.genre = i[13][:128] o.studio = i[14][:128] o.o_site = i[15][:255] o.site = i[16][:255]
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 show_preferences(self): w = self.widgets['preferences'] # image if self.config.get('view_image', 'True')=='False': w['view_image'].set_active(False) else: w['view_image'].set_active(True) # original title if self.config.get('view_otitle', 'True')=='False': w['view_o_title'].set_active(False) else: w['view_o_title'].set_active(True) # title if self.config.get('view_title', 'True')=='False': w['view_title'].set_active(False) else: w['view_title'].set_active(True) # director if self.config.get('view_director', 'True')=='False': w['view_director'].set_active(False) else: w['view_director'].set_active(True) # email reminder if self.config.get('mail_use_auth', 'False') == 'False': w['mail_use_auth'].set_active(False) else: w['mail_use_auth'].set_active(True) w['mail_smtp_server'].set_text(self.config.get('mail_smtp_server', 'localhost')) w['mail_username'].set_text(self.config.get('mail_username', '')) w['mail_password'].set_text(self.config.get('mail_password', '')) w['mail_email'].set_text(self.config.get('mail_email', 'griffith')) # pdf reader w['epdf_reader'].set_text(self.pdf_reader) # pdf font if self.config.get('font'): w['font'].set_filename(self.config.get('font')) # defaults (for static data only) w['condition'].set_active( gutils.digits_only(self.config.get('condition', 0), 5) ) w['region'].set_active( gutils.digits_only(self.config.get('region', 0), 8) ) w['layers'].set_active( gutils.digits_only(self.config.get('layers', 0), 4) ) w['color'].set_active( gutils.digits_only(self.config.get('color', 0), 3 )) if self.config.get('media', 0) in self.media_ids: if self.config.get('media', 0) > 0: w['media'].set_active( gutils.findKey(self.config.get('media', 0), self.media_ids) ) else: w['media'].set_active(0) if self.config.get('vcodec', 0) in self.vcodecs_ids >- 1: if self.config.get('vcodec', 0) > 0: w['vcodec'].set_active( int(gutils.findKey(self.config.get('vcodec', 0), self.vcodecs_ids)) ) else: w['vcodec'].set_active(0) # search for: w['s_classification'].set_active(bool(self.config.get('s_classification', True))) w['s_country'].set_active(bool(self.config.get('s_country', True))) w['s_director'].set_active(bool(self.config.get('s_director', True))) w['s_genre'].set_active(bool(self.config.get('s_genre', True))) w['s_image'].set_active(bool(self.config.get('s_image', True))) w['s_notes'].set_active(bool(self.config.get('s_notes', True))) w['s_o_site'].set_active(bool(self.config.get('s_o_site', True))) w['s_o_title'].set_active(bool(self.config.get('s_o_title', True))) w['s_plot'].set_active(bool(self.config.get('s_plot', True))) w['s_rating'].set_active(bool(self.config.get('s_rating', True))) w['s_runtime'].set_active(bool(self.config.get('s_runtime', True))) w['s_site'].set_active(bool(self.config.get('s_site', True))) w['s_studio'].set_active(bool(self.config.get('s_studio', True))) w['s_title'].set_active(bool(self.config.get('s_title', True))) w['s_trailer'].set_active(bool(self.config.get('s_trailer', True))) w['s_cast'].set_active(bool(self.config.get('s_cast', True))) w['s_year'].set_active(bool(self.config.get('s_year', True))) if self.config.get('sortby'): tmp = self.sort_criteria.index(self.config.get('sortby')) w['sortby'].set_active(tmp) w['sortby_reverse'].set_active(bool(self.config.get('sortby_reverse', False))) plugins = gutils.read_plugins('PluginMovie', \ self.locations['movie_plugins']) plugins.sort() mcounter = 0 for p in plugins: plugin_module = os.path.basename(p).replace('.py','') plugin_name = plugin_module.replace('PluginMovie','') if self.config.get('default_movie_plugin') == plugin_name: w['default_plugin'].set_active(mcounter) self.d_plugin = mcounter mcounter = mcounter + 1 # rating image try: rimage = int(str(self.config.get('rating_image', '0'))) except: rimage = 0 w['rating_image'].set_active(rimage) # spellchecker if self.config.get('use_gtkspell', 'False')=='False': w['spellchecker'].set_active(False) else: w['spellchecker'].set_active(True) if self.config.get('spell_notes', 'True')=='False': w['spell_notes'].set_active(False) else: w['spell_notes'].set_active(True) if self.config.get('spell_plot', 'True')=='False': w['spell_plot'].set_active(False) else: w['spell_plot'].set_active(True) w['spell_lang'].set_text(str(self.config.get('spell_lang', 'en'))) w['amazon_locale'].set_active(self.config.get('amazon_locale', 0)) w['window'].show()
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()