def get_from_web(self): """search the movie in web using the active plugin""" title = self.widgets['add']['title'].get_text() o_title = self.widgets['add']['o_title'].get_text() if o_title or title: option = gutils.on_combo_box_entry_changed_name(self.widgets['add']['source']) self.active_plugin = option plugin_name = 'PluginMovie%s' % option plugin = __import__(plugin_name) self.search_movie = plugin.SearchPlugin() if o_title: self.search_movie.url = self.search_movie.original_url_search self.search_movie.title = gutils.remove_accents(o_title, 'utf-8') elif title: self.search_movie.url = self.search_movie.translated_url_search self.search_movie.title = gutils.remove_accents(title, 'utf-8') self.search_movie.search(self.widgets['add']['window']) self.search_movie.get_searches() if len(self.search_movie.ids) == 1 and o_title and title: self.search_movie.url = self.search_movie.translated_url_search self.search_movie.title = gutils.remove_accents(title, 'utf-8') self.search_movie.search(self.widgets['add']['window']) self.search_movie.get_searches() self.show_search_results(self.search_movie) else: gutils.error(self.widgets['results']['window'], \ _("You should fill the original title\nor the movie title."))
def test_search(self, plugin, title, cntOriginal, cntTranslated): global myconfig result = True plugin.config = myconfig # plugin.translated_url_search plugin.url = plugin.translated_url_search if plugin.remove_accents: plugin.title = gutils.remove_accents(title, 'utf-8') else: plugin.title = title plugin.search_movies(None) plugin.get_searches() if not len(plugin.ids) - 1 == cntOriginal: # first entry is always '' (???) print "Title (Translated): %s - expected: %d - found: %d" % (title, cntOriginal, len(plugin.ids) - 1) result = False # plugin.original_url_search plugin.url = plugin.original_url_search if plugin.remove_accents: plugin.title = gutils.remove_accents(title, 'utf-8') else: plugin.title = title plugin.search_movies(None) plugin.get_searches() if not len(plugin.ids) - 1 == cntTranslated: # first entry is always '' (???) print "Title (Original): %s - expected: %d - found: %d" % (title, cntTranslated, len(plugin.ids) - 1) result = False return result
def get_from_web(self): """search the movie in web using the active plugin""" title = self.widgets['add']['title'].get_text() o_title = self.widgets['add']['o_title'].get_text() if o_title or title: option = gutils.on_combo_box_entry_changed_name( self.widgets['add']['source']) self.active_plugin = option plugin_name = 'PluginMovie%s' % option plugin = __import__(plugin_name) if self.debug_mode: log.debug('reloading %s', plugin_name) import sys reload(sys.modules[plugin_name]) self.search_movie = plugin.SearchPlugin() self.search_movie.config = self.config self.search_movie.locations = self.locations if o_title: self.search_movie.url = self.search_movie.original_url_search if self.search_movie.remove_accents: self.search_movie.title = gutils.remove_accents( o_title, 'utf-8') else: self.search_movie.title = unicode(o_title, 'utf-8') elif title: self.search_movie.url = self.search_movie.translated_url_search if self.search_movie.remove_accents: self.search_movie.title = gutils.remove_accents(title, 'utf-8') else: self.search_movie.title = unicode(title, 'utf-8') # check if internet connection is available try: urllib2.urlopen(self.search_movie.url) if self.search_movie.search_movies(self.widgets['add']['window']): self.search_movie.get_searches() if len(self.search_movie.ids) == 1 and o_title and title: self.search_movie.url = self.search_movie.translated_url_search if self.search_movie.remove_accents: self.search_movie.title = gutils.remove_accents( title, 'utf-8') else: self.search_movie.title = unicode(title, 'utf-8') if self.search_movie.search_movies( self.widgets['add']['window']): self.search_movie.get_searches() self.show_search_results(self.search_movie) except: log.exception('') gutils.error(_("Connection failed.")) else: gutils.error( _("You should fill the original title\nor the movie title."))
def get_from_web(self): """search the movie in web using the active plugin""" title = self.widgets['add']['title'].get_text() o_title = self.widgets['add']['o_title'].get_text() if o_title or title: option = gutils.on_combo_box_entry_changed_name(self.widgets['add']['source']) self.active_plugin = option plugin_name = 'PluginMovie%s' % option plugin = __import__(plugin_name) if self.debug_mode: log.debug('reloading %s', plugin_name) import sys reload(sys.modules[plugin_name]) self.search_movie = plugin.SearchPlugin() self.search_movie.config = self.config self.search_movie.locations = self.locations if o_title: self.search_movie.url = self.search_movie.original_url_search if self.search_movie.remove_accents: self.search_movie.title = gutils.remove_accents(o_title, 'utf-8') else: self.search_movie.title = unicode(o_title, 'utf-8') elif title: self.search_movie.url = self.search_movie.translated_url_search if self.search_movie.remove_accents: self.search_movie.title = gutils.remove_accents(title, 'utf-8') else: self.search_movie.title = unicode(title, 'utf-8') # check if internet connection is available try: urllib2.urlopen("http://www.griffith.cc") if self.search_movie.search_movies(self.widgets['add']['window']): self.search_movie.get_searches() if len(self.search_movie.ids) == 1 and o_title and title: self.search_movie.url = self.search_movie.translated_url_search if self.search_movie.remove_accents: self.search_movie.title = gutils.remove_accents(title, 'utf-8') else: self.search_movie.title = unicode(title, 'utf-8') if self.search_movie.search_movies(self.widgets['add']['window']): self.search_movie.get_searches() self.show_search_results(self.search_movie) except: log.exception('') gutils.error(_("Connection failed.")) else: gutils.error(_("You should fill the original title\nor the movie title."))
def test_search(self, plugin, logFile, title, cntOriginal, cntTranslated): global myconfig result = True plugin.config = myconfig plugin.locations = self.locations # plugin.translated_url_search plugin.url = plugin.translated_url_search if plugin.remove_accents: plugin.title = gutils.remove_accents(title, 'utf-8') else: plugin.title = title plugin.search_movies(None) plugin.get_searches() if not len(plugin.ids ) - 1 == cntOriginal: # first entry is always '' (???) print "Title (Translated): %s - expected: %d - found: %d" % ( title, cntOriginal, len(plugin.ids) - 1) logFile.write( "Title (Translated): %s - expected: %d - found: %d\n\n" % (title, cntOriginal, len(plugin.ids) - 1)) for titleFound in plugin.titles: logFile.write(titleFound) logFile.write('\n') logFile.write('\n\n') result = False # plugin.original_url_search if it is different to plugin.translated_url_search if plugin.original_url_search <> plugin.translated_url_search: plugin.url = plugin.original_url_search if plugin.remove_accents: plugin.title = gutils.remove_accents(title, 'utf-8') else: plugin.title = title plugin.search_movies(None) plugin.get_searches() if not len( plugin.ids ) - 1 == cntTranslated: # first entry is always '' (???) print "Title (Original): %s - expected: %d - found: %d" % ( title, cntTranslated, len(plugin.ids) - 1) logFile.write( "Title (Original): %s - expected: %d - found: %d\n\n" % (title, cntTranslated, len(plugin.ids) - 1)) for titleFound in plugin.titles: logFile.write(titleFound) logFile.write('\n') logFile.write('\n\n') result = False return result
def search(self, parent_window): # replace some standard german umlauts for from_str, to_str in self.translations: self.title = self.title.replace(from_str, to_str) # AFTER that remove accents self.title = gutils.remove_accents(str(self.title)) if not self.open_search(parent_window): return None tmp_pagemovie = self.page # # try to get all result pages (not so nice, but it works) # tmp_pagecount = gutils.trim(tmp_pagemovie, 'Seiten (<b>', '</b>)') try: tmp_pagecountint = int(tmp_pagecount) except: tmp_pagecountint = 1 tmp_pagecountintcurrent = 1 while (tmp_pagecountint > tmp_pagecountintcurrent and tmp_pagecountintcurrent < 5): self.url = "http://www.dvd-palace.de/dvddatabase/dbsearch.php?action=1&start=" + str( tmp_pagecountintcurrent * 20) + "&suchbegriff=" if self.open_search(parent_window): tmp_pagemovie = tmp_pagemovie + self.page tmp_pagecountintcurrent = tmp_pagecountintcurrent + 1 self.page = tmp_pagemovie return self.page
def search(self,parent_window): # replace some standard german umlauts for from_str, to_str in self.translations: self.title = self.title.replace(from_str, to_str) # AFTER that remove accents self.title = gutils.remove_accents(str(self.title)) if not self.open_search(parent_window): return None tmp_pagemovie = self.page # # try to get all result pages (not so nice, but it works) # tmp_pagecount = gutils.trim(tmp_pagemovie, 'Seiten (<b>', '</b>)') try: tmp_pagecountint = int(tmp_pagecount) except: tmp_pagecountint = 1 tmp_pagecountintcurrent = 1 while (tmp_pagecountint > tmp_pagecountintcurrent and tmp_pagecountintcurrent < 5): self.url = "http://www.dvd-palace.de/dvddatabase/dbsearch.php?action=1&start=" + str(tmp_pagecountintcurrent * 20) + "&suchbegriff=" if self.open_search(parent_window): tmp_pagemovie = tmp_pagemovie + self.page tmp_pagecountintcurrent = tmp_pagecountintcurrent + 1 self.page = tmp_pagemovie return self.page
def test_search(self, plugin, title, cnt): plugin.url = plugin.translated_url_search plugin.title = gutils.remove_accents(title, 'utf-8') plugin.search(None) plugin.get_searches() if not len(plugin.ids) - 1 == cnt: # first entry is always '' (???) print "Title: %s - expected: %d - found: %d" % (title, cnt, len(plugin.ids) - 1) return False return True
def test_search(self, plugin, logFile, title, cntOriginal, cntTranslated): global debug, myconfig result = True plugin.debug = debug plugin.config = myconfig # plugin.translated_url_search plugin.url = plugin.translated_url_search if plugin.remove_accents: plugin.title = gutils.remove_accents(title, "utf-8") else: plugin.title = title plugin.search_movies(None) plugin.get_searches() if not len(plugin.ids) - 1 == cntOriginal: # first entry is always '' (???) print "Title (Translated): %s - expected: %d - found: %d" % (title, cntOriginal, len(plugin.ids) - 1) logFile.write( "Title (Translated): %s - expected: %d - found: %d\n\n" % (title, cntOriginal, len(plugin.ids) - 1) ) for titleFound in plugin.titles: logFile.write(titleFound) logFile.write("\n") logFile.write("\n\n") result = False # plugin.original_url_search plugin.url = plugin.original_url_search if plugin.remove_accents: plugin.title = gutils.remove_accents(title, "utf-8") else: plugin.title = title plugin.search_movies(None) plugin.get_searches() if not len(plugin.ids) - 1 == cntTranslated: # first entry is always '' (???) print "Title (Original): %s - expected: %d - found: %d" % (title, cntTranslated, len(plugin.ids) - 1) logFile.write( "Title (Original): %s - expected: %d - found: %d\n\n" % (title, cntTranslated, len(plugin.ids) - 1) ) for titleFound in plugin.titles: logFile.write(titleFound) logFile.write("\n") logFile.write("\n\n") result = False return result
def get_from_web(self): """search the movie in web using the active plugin""" if len(self.am_original_title.get_text()) \ or len(self.am_title.get_text()): option = gutils.on_combo_box_entry_changed_name(self.am_source) self.active_plugin = option plugin_name = 'PluginMovie%s' % option plugin = __import__(plugin_name) self.search_movie = plugin.SearchPlugin() if len(self.am_original_title.get_text()): self.search_movie.url = self.search_movie.original_url_search self.search_movie.title = \ gutils.remove_accents(self.am_original_title.get_text(), 'utf-8') elif len(self.am_title.get_text()) \ and not len(self.am_original_title.get_text()): self.search_movie.url = self.search_movie.translated_url_search self.search_movie.title = \ gutils.remove_accents(self.am_title.get_text(), 'utf-8') self.search_movie.search(self.add_movie_window) self.search_movie.get_searches() self.show_search_results(self.search_movie) else: gutils.error(self.w_results, \ _("You should fill the original title\nor the movie title."))
def populate_with_results(self): m_id = None if self.founded_results_id: self.debug.show("self.founded:results_id: %s" % self.founded_results_id) m_id = self.founded_results_id else: self.founded_results_id = 0 treeselection = self.results_treeview.get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() m_id = tmp_model.get_value(tmp_iter, 0) self.hide_results() try: self.debug.show("m_id: %s" % m_id) except: self.debug.show("m_id: Bad UNICODE character") plugin_name = 'PluginMovie' + self.active_plugin plugin = __import__(plugin_name) self.movie = plugin.Plugin(m_id) self.movie.open_page(self.add_movie_window) self.movie.parse_movie() self.am_original_title.set_text(gutils.convert_entities(self.movie.original_title)) self.am_title.set_text(gutils.convert_entities(self.movie.title)) self.am_director.set_text(gutils.convert_entities(self.movie.director)) plot_buffer = self.am_plot.get_buffer() plot_buffer.set_text(gutils.convert_entities(self.movie.plot)) with_buffer = self.am_with.get_buffer() with_buffer.set_text(gutils.convert_entities(self.movie.with)) self.am_country.set_text(gutils.convert_entities(self.movie.country)) self.am_genre.set_text(gutils.convert_entities(self.movie.genre)) self.am_classification.set_text(gutils.convert_entities(self.movie.classification)) self.am_studio.set_text(gutils.convert_entities(self.movie.studio)) self.am_site.set_text(gutils.remove_accents(self.movie.site)) self.am_imdb.set_text(gutils.remove_accents(self.movie.imdb)) self.am_trailer.set_text(gutils.remove_accents(self.movie.trailer)) self.am_year.set_text(self.movie.year) notes_buffer = self.am_obs.get_buffer() notes_buffer.set_text(gutils.convert_entities(self.movie.notes)) self.am_runtime.set_text(self.movie.running_time) if self.movie.rating: self.rating_slider_add.set_value(float(self.movie.rating)) # poster if self.windows: temp_dir = "C:\\windows\\temp\\" else: temp_dir = "/tmp/" if self.movie.picture != "": image = os.path.join(temp_dir, self.movie.picture) try: handler = self.Image.set_from_file(image) pixbuf = self.Image.get_pixbuf() self.am_picture.set_from_pixbuf(pixbuf.scale_simple(100, 140, 3)) self.am_picture_name.set_text(string.replace(self.movie.picture, ".jpg","")) except: image = os.path.join(self.locations['images'], "default.png") handler = self.Image.set_from_file(image) self.am_picture.set_from_pixbuf(self.Image.get_pixbuf()) else: image = os.path.join(self.locations['images'], "default.png") handler = self.Image.set_from_file(image) Pixbuf = self.Image.get_pixbuf() self.am_picture.set_from_pixbuf(Pixbuf) def show_websearch_results(self): total = self.founded_results_id = 0 for g in self.search_movie.ids: if ( str(g) != '' ): total += 1 if total > 1: self.w_results.show() self.w_results.set_keep_above(True) row = None key = 0 self.treemodel_results.clear() for row in self.search_movie.ids: if (str(row)!=''): title = str(self.search_movie.titles[key]).decode(self.search_movie.encode) myiter = self.treemodel_results.insert_before(None, None) self.treemodel_results.set_value(myiter, 0, str(row)) self.treemodel_results.set_value(myiter, 1, title) key +=1 self.results_treeview.show() elif total==1: self.results_treeview.set_cursor(total-1) for row in self.search_movie.ids: if ( str(row) != '' ): self.founded_results_id = str(row) populate_with_results(self) else: gutils.error(self.w_results, _("No results"), self.add_movie_window) def get_from_web(self): """search the movie in web using the active plugin""" if len(self.am_original_title.get_text()) \ or len(self.am_title.get_text()): option = gutils.on_combo_box_entry_changed_name(self.am_source) self.active_plugin = option plugin_name = 'PluginMovie%s' % option plugin = __import__(plugin_name) self.search_movie = plugin.SearchPlugin() if len(self.am_original_title.get_text()): self.search_movie.url = self.search_movie.original_url_search self.search_movie.title = \ gutils.remove_accents(self.am_original_title.get_text(), 'utf-8') elif len(self.am_title.get_text()) \ and not len(self.am_original_title.get_text()): self.search_movie.url = self.search_movie.translated_url_search self.search_movie.title = \ gutils.remove_accents(self.am_title.get_text(), 'utf-8') self.search_movie.search(self.add_movie_window) self.search_movie.get_searches() self.show_search_results(self.search_movie) else: gutils.error(self.w_results, \ _("You should fill the original title\nor the movie title.")) def source_changed(self): option = gutils.on_combo_box_entry_changed_name(self.am_source) self.active_plugin = option plugin_name = 'PluginMovie' + option plugin = __import__(plugin_name) self.am_plugin_desc.set_text(plugin.plugin_name+"\n" \ +plugin.plugin_description+"\n"+_("Url: ") \ +plugin.plugin_url+"\n"+_("Language: ")+plugin.plugin_language) image = os.path.join(self.locations['images'], plugin_name + ".png") # if movie plugin logo exists lets use it if os.path.exists(image): handler = self.am_plugin_image.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(image)) def clone_movie(self): treeselection = self.main_treeview.get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() m_id = tmp_model.get_value(tmp_iter, 1) movie_id = self.db.get_value(field="id", table="movies", where="number='%s'"%m_id) if movie_id == None: return false row = self.db.select_movie_by_num(m_id)[0] next_number = gutils.find_next_available(self) new_image = str(row['image']) + '_' + str(next_number) self.db.cursor.execute( """INSERT INTO 'movies' ('id','original_title','title','director','plot','image', 'year','runtime','actors','country','genre','media','classification','studio', 'site','color','region','layers','condition','imdb','trailer','obs','num_media', 'rating','loaned','seen','number') VALUES (Null,'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','0','%s','%s')""" % \ (gutils.gescape(str(row['original_title'])), \ gutils.gescape(str(row['title'])), \ gutils.gescape(str(row['director'])), \ gutils.gescape(str(row['plot'])), \ gutils.gescape(new_image), \ gutils.gescape(str(row['year'])), \ gutils.gescape(str(row['runtime'])), \ gutils.gescape(str(row['actors'])), \ gutils.gescape(str(row['country'])), \ gutils.gescape(str(row['genre'])), \ gutils.gescape(str(row['media'])), \ gutils.gescape(str(row['classification'])), \ gutils.gescape(str(row['studio'])), \ gutils.gescape(str(row['site'])), \ gutils.gescape(str(row['color'])), \ gutils.gescape(str(row['region'])), \ gutils.gescape(str(row['layers'])), \ gutils.gescape(str(row['condition'])), \ gutils.gescape(str(row['imdb'])), \ gutils.gescape(str(row['trailer'])), \ gutils.gescape(str(row['obs'])), \ str(row['num_media']), \ str(row['rating']), \ str(row['seen']), \ str(next_number) )\ ) # dont copy volume/collection data (loan problems) next_movie_id = self.db.get_value(field="id", table="movies", where="number='%s'"%next_number) # tags for item in self.db.get_all_data(table_name="movie_tag",what="tag_id", where="movie_id='%s'"%movie_id): self.db.cursor.execute(""" INSERT INTO movie_tag('movie_id','tag_id') VALUES('%s','%s')""" % \ (next_movie_id, item['tag_id'])) # languages for item in self.db.get_all_data(table_name="movie_lang",what="lang_id, type", where="movie_id='%s'"%movie_id): self.db.cursor.execute(""" INSERT INTO movie_lang('movie_id','lang_id', 'type') VALUES('%s','%s', '%s')""" % \ (next_movie_id, item['lang_id'], item['type'])) tmp_dest = os.path.join(self.griffith_dir, "posters") if str(str(row['image'])) != '': image_path = os.path.join(tmp_dest, str(row['image'])+".jpg") clone_path = os.path.join(tmp_dest, new_image+".jpg") # clone image shutil.copyfile(image_path, clone_path) image_path = clone_path else: if self.windows: image_path = "images/default.png" else: image_path = os.path.join(self.locations['images'], "default.png") handler = self.Image.set_from_file(image_path) #update statusbar self.total = self.total + 1 self.total_filter = self.total self.count_statusbar() self.populate_treeview(self.db.get_all_data(order_by="number ASC")) self.main_treeview.set_cursor(next_number-1) self.treeview_clicked()