diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/NEWS trunk/NEWS --- ../BUILD.i686-linux/griffith-0.13/NEWS 2011-12-19 00:30:41.000000000 +0200 +++ trunk/NEWS 2013-07-27 18:37:07.490294405 +0300 @@ -2,7 +2,7 @@ ============= * New movie plugins: AllRovi, IMDB-pt, Interfilmes * Most movie plugins updated, - - AniDB plugin requires lxml module now (new 4rd party dependency) + - AniDB plugin requires lxml module now (new 3rd party dependency) * New extensions: Database Cleanup and Maintenance * MacOSX integration improved * Many bug fixes diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/README trunk/README --- ../BUILD.i686-linux/griffith-0.13/README 2010-10-18 22:55:15.000000000 +0300 +++ trunk/README 2013-07-27 18:37:04.400158088 +0300 @@ -1,4 +1,4 @@ -Griffith 0.12.1 README +Griffith 0.13.0 README ====================== This document was last updated on Thu Jun 10 2009. Only in trunk/: debian Only in ../BUILD.i686-linux/griffith-0.13/glade: exporthtml.glade.h Only in ../BUILD.i686-linux/griffith-0.13/glade: griffith.glade.h Only in ../BUILD.i686-linux/griffith-0.13/glade: import.glade.h Only in ../BUILD.i686-linux/griffith-0.13/glade: importcsv.glade.h Only in ../BUILD.i686-linux/griffith-0.13/: griffith-extra-artwork-0.9.4 diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/add.py trunk/lib/add.py --- ../BUILD.i686-linux/griffith-0.13/lib/add.py 2011-10-03 21:34:23.000000000 +0300 +++ trunk/lib/add.py 2013-07-27 18:37:05.100188969 +0300 @@ -1,7 +1,7 @@ # -*- coding: UTF-8 -*- # vim: fdm=marker -__revision__ = '$Id: add.py 1595 2011-10-02 19:25:14Z mikej06 $' +__revision__ = '$Id: add.py 1645 2013-04-02 18:57:40Z mikej06 $' # Copyright (c) 2005-2011 Vasco Nunes, Piotr Ożarowski # @@ -245,19 +245,23 @@ if total > 1: self.widgets['results']['window'].show() self.widgets['results']['window'].set_keep_above(True) + movieslist = [] row = None key = 0 - self.treemodel_results.clear() for row in self.search_movie.ids: if (str(row) != ''): if isinstance(self.search_movie.titles[key], unicode): title = self.search_movie.titles[key] else: 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) + movieslist.append((row, title)) key += 1 + movieslist = sorted(movieslist, key=lambda titel: titel[1]) + self.treemodel_results.clear() + for entry in movieslist: + myiter = self.treemodel_results.insert_before(None, None) + self.treemodel_results.set_value(myiter, 0, str(entry[0])) + self.treemodel_results.set_value(myiter, 1, entry[1]) self.widgets['results']['treeview'].show() elif total == 1: self.widgets['results']['treeview'].set_cursor(total-1) @@ -301,7 +305,7 @@ self.search_movie.title = unicode(title, 'utf-8') # check if internet connection is available try: - urllib2.urlopen(self.search_movie.url) + 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: diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/backup.py trunk/lib/backup.py --- ../BUILD.i686-linux/griffith-0.13/lib/backup.py 2011-02-17 19:17:36.000000000 +0200 +++ trunk/lib/backup.py 2013-07-27 18:37:06.320242790 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: backup.py 1539 2011-02-17 00:31:19Z iznogoud $' +__revision__ = '$Id: backup.py 1632 2012-12-16 21:15:57Z mikej06 $' # Copyright (c) 2005-2009 Vasco Nunes, Piotr Ożarowski # @@ -85,10 +85,12 @@ file_path = os.path.join(self.locations['home'], db_file_name).encode('utf-8') mzip.write(file_path, arcname=db_file_name) else: + tmp_engine = None try: tmp_dir = mkdtemp() - tmp_config = copy.deepcopy(self.config) - tmp_config._file = os.path.join(tmp_dir, 'griffith.cfg') + tmp_config_file = os.path.join(tmp_dir, 'griffith.cfg') + self.config.save(tmp_config_file) + tmp_config = config.Config(file=tmp_config_file) tmp_config.set('type', 'sqlite', section='database') tmp_config.set('file', 'griffith.db', section='database') tmp_config.set('name', 'griffith', section='database') @@ -114,7 +116,8 @@ mzip.write(tmp_file, arcname='griffith.db') finally: # disposing the temporary db connection before rmtree and in finally block to avoid locked db file - tmp_engine.dispose() + if tmp_engine: + tmp_engine.dispose() rmtree(tmp_dir) gutils.info(_("Backup has been created"), self.widgets['window']) @@ -200,7 +203,7 @@ * SQLite3 *.db file """ # let user select a backup file - filename = gutils.file_chooser(_("Restore Griffith backup"), \ + filename, path = gutils.file_chooser(_("Restore Griffith backup"), \ action=gtk.FILE_CHOOSER_ACTION_OPEN, backup=True, \ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) if not filename: diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/config.py trunk/lib/config.py --- ../BUILD.i686-linux/griffith-0.13/lib/config.py 2011-01-19 17:53:44.000000000 +0200 +++ trunk/lib/config.py 2013-07-27 18:37:06.323576270 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: config.py 1502 2011-01-19 15:52:19Z mikej06 $' +__revision__ = '$Id: config.py 1632 2012-12-16 21:15:57Z mikej06 $' # Copyright © 2005-2011 Vasco Nunes, Piotr Ożarowski # @@ -85,10 +85,12 @@ d[i] = j return d - def save(self): - if not os.path.exists(os.path.split(self._file)[0]): - os.makedirs(os.path.split(self._file)[0]) - self._cfg.write(open(self._file, 'w')) + def save(self, file = None): + if not file: + file = self._file + if not os.path.exists(os.path.split(file)[0]): + os.makedirs(os.path.split(file)[0]) + self._cfg.write(open(file, 'w')) def load(self): if os.path.isfile(self._file): diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/db/validators.py trunk/lib/db/validators.py --- ../BUILD.i686-linux/griffith-0.13/lib/db/validators.py 2011-06-14 23:02:24.000000000 +0300 +++ trunk/lib/db/validators.py 2013-07-27 18:37:06.076898722 +0300 @@ -23,7 +23,13 @@ import logging -from sqlalchemy.orm.interfaces import AttributeExtension, InstrumentationManager +from sqlalchemy.orm.interfaces import AttributeExtension +try: + # sql alchemy 0.8 (and above) + from sqlalchemy.ext.instrumentation import InstrumentationManager +except: + # sql alchemy 0.7 + from sqlalchemy.orm.interfaces import InstrumentationManager from sqlalchemy.orm import ColumnProperty from sqlalchemy.types import String diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/edit.py trunk/lib/edit.py --- ../BUILD.i686-linux/griffith-0.13/lib/edit.py 2011-08-23 23:51:34.000000000 +0300 +++ trunk/lib/edit.py 2013-07-27 18:37:06.326909751 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: edit.py 1572 2011-08-23 18:47:22Z mikej06 $' +__revision__ = '$Id: edit.py 1619 2012-01-29 19:11:45Z mikej06 $' # Copyright © 2005-2011 Vasco Nunes, Piotr Ożarowski @@ -152,5 +152,5 @@ def update_tree_thumbnail(self, t_image_path): self.Image.set_from_file(t_image_path) pixbuf = self.Image.get_pixbuf() - if self.selected_iter[0]: + if len(self.selected_iter) > 0 and self.selected_iter[0]: self.treemodel.set_value(self.selected_iter[0], 1, pixbuf) \ No newline at end of file diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/initialize.py trunk/lib/initialize.py --- ../BUILD.i686-linux/griffith-0.13/lib/initialize.py 2011-12-04 17:59:11.000000000 +0200 +++ trunk/lib/initialize.py 2013-07-27 18:37:06.320242790 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: initialize.py 1600 2011-12-02 20:30:27Z mikej06 $' +__revision__ = '$Id: initialize.py 1622 2012-04-10 17:07:16Z iznogoud $' # Copyright © 2005-2011 Vasco Nunes, Piotr Ożarowski # @@ -50,14 +50,11 @@ if defaultEnc is None: defaultEnc = 'UTF-8' locations = {} - locations['exec'] = os.path.abspath(os.path.dirname(sys.argv[0])) # deprecated + locations['exec'] = os.path.abspath(os.path.dirname(sys.argv[0])) # deprecated locations['lib'] = os.path.dirname(__file__) locations['home'] = home_dir - if os.name == 'nt' or os.name.startswith('win'): # win32, win64 - import winshell - from win32com.shell import shellcon, shell - + if os.name == 'nt' or os.name.startswith('win'): # win32, win64 locations['movie_plugins'] = "%s\\lib\\plugins\\movie" % locations['exec'] locations['export_plugins'] = "%s\\lib\\plugins\\export" % locations['exec'] locations['images'] = "%s\\images" % locations['exec'] @@ -165,6 +162,7 @@ self.widgets['extensions']['toolbar_hb'].show() self.widgets['menu']['ext_toolbar'].set_active(True) + def treeview(self): import main_treeview # set up the treeview to do multiple selection @@ -174,7 +172,7 @@ tree.set_headers_visible(True) tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.widgets['treeview'].get_selection().connect("changed", main_treeview.on_tree_selection, self) - + # number column renderer = gtk.CellRendererText() self.number_column = gtk.TreeViewColumn(_('No.'), renderer, text=0) @@ -280,6 +278,7 @@ self.updated_column.set_alignment(0.5) self.updated_column.set_reorderable(True) self.widgets['treeview'].append_column(self.updated_column) + # reflect saved column order and column sizes columnorder = self.config.get('columnorder', None, section='mainlist') if columnorder: @@ -319,7 +318,7 @@ self.total = self.db.session.query(db.Movie).count() self.widgets['treeview'].set_search_equal_func(search_func_treeview) self.widgets['treeview'].show() - + # adding some completion fields - TODO: move it to initialize self.completion = gtk.EntryCompletion() self.widgets['add']['o_title'].set_completion(self.completion) @@ -331,14 +330,15 @@ self.completion_t.set_model(self.treemodel) self.completion_t.set_text_column(4) + def search_func_treeview(model, column, key, iter): - return not (str(model.get_value(iter, 0)).startswith(key) or - str(model.get_value(iter, 2)).lower().startswith(key.lower()) or + return not (str(model.get_value(iter, 0)).startswith(key) or + str(model.get_value(iter, 2)).lower().startswith(key.lower()) or str(model.get_value(iter, 3)).lower().startswith(key.lower())) def loans_treeview(self): - self.loans_treemodel = gtk.TreeStore(str, str, str) # move to self.widgets + self.loans_treemodel = gtk.TreeStore(str, str, str) # move to self.widgets self.widgets['movie']['loan_history'].set_model(self.loans_treemodel) self.widgets['movie']['loan_history'].set_headers_visible(True) # loan date @@ -540,7 +540,7 @@ for i in fields_to_import: j = j + 1 w['fields'][i] = gtk.CheckButton(self.field_names[i]) - w['fields'][i].set_active(True) # TODO: get from config + w['fields'][i].set_active(True) # TODO: get from config if j <= k: w['box_import_1'].add(w['fields'][i]) elif j <= 2 * k: @@ -583,7 +583,6 @@ def extension_preferences(self, module, enabled): # preferences window p_vbox = self.widgets['extensions']['preferences_vbox'] - configwidgets = {} label = "%s v%s (%s <%s>)" % (module.name, module.version, module.author, module.email) @@ -615,6 +614,9 @@ w.insert_text(value) # TODO: min, max # elif type is int: # TODO + elif type_ is bool: + w = gtk.CheckButton() + w.set_active(bool(value)) elif isinstance(type_, (list, tuple, dict)): model = gtk.TreeStore(str, str) if isinstance(type_, dict): @@ -665,7 +667,7 @@ if hasattr(self, 'extensions'): for ext in self.extensions: ext.clear() - self.extensions = [] # deletes previous instances + self.extensions = [] # deletes previous instances for ext_name in plugins.extensions.by_name: ext_module = plugins.extensions.by_name[ext_name] @@ -730,7 +732,7 @@ pos_to_activate = 0 selected_criteria = self.config.get('criteria', None, section='mainlist') self.search_criteria_sorted = sorted((self.field_names[criteria], criteria) for criteria in self.search_criteria) - self.search_criteria_sorted.insert( 0, ( _('Any'), 'any' ) ) + self.search_criteria_sorted.insert(0, (_('Any'), 'any')) for (criterianame, criteria) in self.search_criteria_sorted: self.widgets['filter']['criteria'].insert_text(i, criterianame) if selected_criteria == criterianame: @@ -745,12 +747,12 @@ self.widgets['preferences']['sortby'].insert_text(i, _('Last added')) i += 1 self.widgets['preferences']['sortby'].set_wrap_width(3) - self.widgets['preferences']['sortby'].set_active(0) # Number + self.widgets['preferences']['sortby'].set_active(0) # Number def dictionaries(self): """initializes data filled dynamically by users""" - self.am_tags = {} # dictionary for tag CheckBoxes + self.am_tags = {} # dictionary for tag CheckBoxes update_volume_combo_ids(self) update_collection_combo_ids(self) fill_volumes_combo(self) @@ -765,7 +767,7 @@ vcodec_combos(self) media_combos(self) create_tag_vbox(self, widget=self.widgets['add']['tag_vbox'], tab=self.am_tags) - self.sort_criteria = [ # "[]" because of index() + self.sort_criteria = [ # "[]" because of index() 'number', 'o_title', 'title', 'director', 'year', 'runtime', 'country', 'genre', 'studio', 'media_num', 'rating', 'classification', 'collection_id', 'volume_id', 'cond', 'layers', 'region', 'movie_id'] @@ -851,9 +853,9 @@ spell_error = False if self.posix and spell_support: if self.config.get('gtkspell', False, section='spell') == True: - if self.config.get('notes', True, section='spell') == True and self.config.get('lang', section='spell') != '': + if self.config.get('notes', True, section='spell') is True and self.config.get('lang', section='spell') != '': try: - self.notes_spell = gtkspell.Spell(self.widgets['add']['cast'], self.config.get('lang', section='spell')) + self.notes_spell = gtkspell.Spell(self.widgets['add']['notes'], self.config.get('lang', section='spell')) except: spell_error = True if self.config.get('plot', True, section='spell') is True and self.config.get('lang', section='spell') != '': @@ -921,7 +923,7 @@ def fill_volumes_combo(self, default=0): _tmp = self.initialized - self.initialized = False # don't refresh main treeview + self.initialized = False # don't refresh main treeview self.widgets['add']['volume'].get_model().clear() for i in self.volume_combo_ids: vol_id = self.volume_combo_ids[i] @@ -940,7 +942,7 @@ def fill_collections_combo(self, default=0): _tmp = self.initialized - self.initialized = False # don't refresh main treeview + self.initialized = False # don't refresh main treeview self.widgets['add']['collection'].get_model().clear() self.widgets['filter']['collection'].get_model().clear() for i in self.collection_combo_ids: @@ -964,9 +966,9 @@ def fill_advfilter_combo(self): _tmp = self.initialized - self.initialized = False # don't refresh main treeview + self.initialized = False # don't refresh main treeview self.widgets['filter']['advfilter'].get_model().clear() - self.widgets['filter']['advfilter'].insert_text(0, '') # empty one + self.widgets['filter']['advfilter'].insert_text(0, '') # empty one for i, item in enumerate(self.db.session.query(db.Filter.name).order_by(db.Filter.name).all()): # add some white spaces to prevent scrollbar hides parts of the names self.widgets['filter']['advfilter'].insert_text(i + 1, item.name + ' ') @@ -977,7 +979,7 @@ def fill_preferences_tags_combo(self): _tmp = self.initialized - self.initialized = False # don't refresh main treeview + self.initialized = False # don't refresh main treeview self.widgets['preferences']['tag_name'].get_model().clear() self.tags_ids = {} for i, tag in enumerate(self.db.session.query(db.Tag.name, db.Tag.tag_id).all()): @@ -990,7 +992,7 @@ def fill_resolutions_combo(self, default=0): _tmp = self.initialized - self.initialized = False # don't refresh main treeview + self.initialized = False # don't refresh main treeview self.widgets['add']['resolution'].get_model().clear() #resolutions = [names[0] for names in db._movie.res_aliases.values()] resolutions = [names[0] for (res, names) in db._movie.res_aliases.iteritems()] @@ -1086,7 +1088,7 @@ self.widgets['preferences']['media'].show_all() if self.config.has_key('media', section='defaults'): pos = gutils.findKey(self.config.get('media', section='defaults'), self.media_ids) - if pos is not None: + if pos is not None: self.widgets['preferences']['media'].set_active(int(pos)) else: self.widgets['preferences']['media'].set_active(0) @@ -1138,7 +1140,7 @@ def remove_hbox(self, widget, tab): - number = len(widget.get_children())-1 # last box number + number = len(widget.get_children()) - 1 # last box number try: tab.pop() widget.remove(widget.get_children().pop()) diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/main_treeview.py trunk/lib/main_treeview.py --- ../BUILD.i686-linux/griffith-0.13/lib/main_treeview.py 2011-08-23 23:51:34.000000000 +0300 +++ trunk/lib/main_treeview.py 2013-07-27 18:37:06.076898722 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: main_treeview.py 1572 2011-08-23 18:47:22Z mikej06 $' +__revision__ = '$Id: main_treeview.py 1616 2012-01-23 21:07:53Z piotrek $' # Copyright (c) 2005-2011 Vasco Nunes, Piotr Ożarowski @@ -24,7 +24,6 @@ import logging import os import gtk -from sqlalchemy import select, desc from sqlalchemy.sql.expression import Select import db import gutils @@ -32,12 +31,13 @@ log = logging.getLogger("Griffith") + def on_tree_selection(tree_selection, self): counts = tree_selection.count_selected_rows() treeview_selection_on_event(self, self.widgets['treeview']) treemodel, selected = tree_selection.get_selected_rows() self.selected_iter = [treemodel.get_iter(path) for path in selected] - + if counts == 1: # TODO: rewrite me self.widgets['menu']['clone'].set_sensitive(True) @@ -62,14 +62,17 @@ self.widgets['popups']['print_cover'].set_sensitive(False) treeview_clicked(self) + def foreach_treeview_selected(model, path, iter, selected): selected.append(model.get_value(iter, 0)) -def treeview_selection_on_event(self, treeview, iter = False): + +def treeview_selection_on_event(self, treeview, iter=False): self.selected = [] treeview.get_selection().selected_foreach(foreach_treeview_selected, self.selected) #return selected + def treeview_clicked(self): if self.initialized is False: return False @@ -89,7 +92,8 @@ else: return False -def set_details(self, item=None):#{{{ + +def set_details(self, item=None): # {{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: @@ -127,7 +131,7 @@ 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' + else: # fallback to 'resolution' w['resolution'].set_text(item['resolution']) else: w['resolution'].set_text('') @@ -172,10 +176,10 @@ 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 + 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 + 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("%s" % self._layers[item['layers']]) @@ -303,7 +307,7 @@ 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 + 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) @@ -358,7 +362,7 @@ i.destroy() if 'languages' in item and len(item['languages']) > 0: for i in item['languages']: - if i.type == 3: # subtitles + if i.type == 3: # subtitles if i.subformat: tmp = "%s - %s" % (i.language.name, i.subformat.name) else: @@ -390,21 +394,21 @@ tmp = '' for tag in item['tags']: tmp += "%s, " % tag.name - tmp = tmp[:-2] # cut last comma + tmp = tmp[:-2] # cut last comma w['tags'].set_text(tmp) #}}} -def populate(self, movies=None, where=None, qf=True):#{{{ - if self.initialized is False: # dont try to fill movie list if Griffith is not initialized yet +def populate(self, movies=None, where=None, qf=True): # {{{ + if self.initialized is False: # dont try to fill movie list if Griffith is not initialized yet return False - if qf and movies is None or isinstance(movies, Select): # if ".execute().fetchall()" not invoked on movies yet - if not where: # due to possible 'seen', 'loaned', 'collection_id' in where + if qf and movies is None or isinstance(movies, Select): # if ".execute().fetchall()" not invoked on movies yet + if not where: # due to possible 'seen', 'loaned', 'collection_id' in where import advfilter # saved in advfilter - name = self.widgets['filter']['advfilter'].get_active_text()[:-3].decode('utf-8') # :-3 due to additional ' ' in the name + name = self.widgets['filter']['advfilter'].get_active_text()[:-3].decode('utf-8') # :-3 due to additional ' ' in the name if name: cond = self.db.session.query(db.Filter).filter_by(name=name).first() if not cond: @@ -529,13 +533,15 @@ self.count_statusbar() #}}} -def addmovie(self, movie): #{{{ + +def addmovie(self, movie): # {{{ myiter = self.treemodel.append(None) setmovie(self, movie, myiter) return myiter #}}} -def setmovie(self, movie, iter, treemodel = None): #{{{ + +def setmovie(self, movie, iter, treemodel=None): # {{{ if not treemodel: treemodel = self.treemodel @@ -573,7 +579,8 @@ return iter #}}} -def select(self, iter, ensurevisible = True): #{{{ + +def select(self, iter, ensurevisible=True): # {{{ if iter: self.widgets['treeview'].get_selection().select_iter(iter) if ensurevisible: diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/export/PluginExportPDF.py trunk/lib/plugins/export/PluginExportPDF.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/export/PluginExportPDF.py 2011-02-08 23:10:58.000000000 +0200 +++ trunk/lib/plugins/export/PluginExportPDF.py 2013-07-27 18:37:05.820220732 +0300 @@ -1,8 +1,8 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: PluginExportPDF.py 1533 2011-02-08 21:04:38Z iznogoud $' +__revision__ = '$Id: PluginExportPDF.py 1648 2013-06-01 18:25:04Z mikej06 $' -# Copyright (c) 2005-2010 Vasco Nunes +# Copyright (c) 2005-2013 Vasco Nunes # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -42,20 +42,34 @@ import gutils import version from plugins.export import Base +import logging + +log = logging.getLogger("Griffith") class ExportPlugin(Base): name = "PDF" description = _("PDF export plugin") author = "Vasco Nunes" email = "" - version = "0.6" + version = "0.7" - fields_to_export = ('number', 'o_title', 'title', 'director', 'genre', 'cast', 'plot', 'runtime', 'year', 'notes', 'poster_md5') + fields_to_export = ('number', 'o_title', 'title', 'director', 'genre', 'cast', 'plot', 'runtime', 'year', 'notes', 'poster_md5', 'width', 'height', 'volumes.name', 'collections.name') def initialize(self): self.fontName = '' return True + def _get_resolution(self, movie): + if not movie.movies_width or not movie.movies_height: + return '' + from db._movie import res_aliases + resolution = (movie.movies_width, movie.movies_height) + if resolution in res_aliases: + return res_aliases[resolution][0] + else: + res_string = "%dx%d" % resolution + return res_string + def run(self): """exports a simple movie list to a pdf file""" @@ -79,124 +93,142 @@ overwrite = False if overwrite == True or overwrite is None: - # filename encoding - defaultLang, defaultEnc = getdefaultlocale() - if defaultEnc is None: - defaultEnc = 'UTF-8' - c = SimpleDocTemplate(pdffilename.encode(defaultEnc), \ - author = 'Griffith', \ - title = _('List of films').encode('utf-8'), \ - subject = _('List of films').encode('utf-8')) - # data encoding - #if defaultEncoding == 'WinAnsiEncoding': - # defaultEnc = 'cp1252' - #else: - defaultEnc = 'utf-8' - - pdf_elements = self.config.get('pdf_elements', 'image,director,genre,cast').split(',') - - self.create_styles() - style = self.styles["Normal"] - Story = [Spacer(1,2*inch)] - - # select sort column - FIXME - sort_column_name = self.config.get('sortby', 'number', section='mainlist') - sort_reverse = self.config.get('sortby_reverse', False, section='mainlist') - do_grouping = True - for i in sort_column_name.split(','): - if i != 'title' and i != 'o_title': - do_grouping = False - - # build the query - query = self.get_query() - movies = query.execute().fetchall() - - # define some custom stylesheetfont - total = len(movies) - p = Paragraph(saxutils.escape((_("List of films")).encode('utf-8')), self.styles["Heading1"] ) - Story.append(p) - Story.append(Paragraph(" ",style)) - p = Paragraph(saxutils.escape((_("Total Movies: %s") % str(total)).encode('utf-8')), self.styles["Heading3"]) - Story.append(p) - Story.append(Paragraph(" ",style)) - # output movies - first_letter = '' - for movie in movies: - number = movie.number - if movie.o_title: - original_title = movie.o_title.encode(defaultEnc) - else: - original_title = '' - if movie.title: - title = movie.title.encode(defaultEnc) - else: - title = '' - grouping_title = movie.title - if grouping_title is None: - grouping_title = u'None' - if movie.director: - director = ' - ' + movie.director.encode(defaultEnc) - else: - director = "" - # group by first letter - # use movie.title/grouping_title for grouping because of encoding problems !!! - if do_grouping and grouping_title[0] != first_letter: - if grouping_title[0] in '0123456789': - # Group Numbers - if first_letter != '0-9': - first_letter = '0-9' + try: + # filename encoding + defaultLang, defaultEnc = getdefaultlocale() + if defaultEnc is None: + defaultEnc = 'UTF-8' + c = SimpleDocTemplate(pdffilename.encode(defaultEnc), \ + author = 'Griffith', \ + title = _('List of films').encode('utf-8'), \ + subject = _('List of films').encode('utf-8'), \ + allowSplitting = False) + # data encoding + #if defaultEncoding == 'WinAnsiEncoding': + # defaultEnc = 'cp1252' + #else: + defaultEnc = 'utf-8' + + pdf_elements = self.config.get('pdf_elements', 'image,director,genre,cast').split(',') + + self.create_styles() + style = self.styles["Normal"] + Story = [Spacer(1,2*inch)] + + # select sort column - FIXME + sort_column_name = self.config.get('sortby', 'number', section='mainlist') + sort_reverse = self.config.get('sortby_reverse', False, section='mainlist') + do_grouping = True + for i in sort_column_name.split(','): + if i != 'title' and i != 'o_title': + do_grouping = False + + # build the query + query = self.get_query() + movies = query.execute().fetchall() + + # define some custom stylesheetfont + total = len(movies) + p = Paragraph(saxutils.escape((_("List of films")).encode('utf-8')), self.styles["Heading1"] ) + Story.append(p) + Story.append(Paragraph(" ",style)) + p = Paragraph(saxutils.escape((_("Total Movies: %s") % str(total)).encode('utf-8')), self.styles["Heading3"]) + Story.append(p) + Story.append(Paragraph(" ",style)) + # output movies + first_letter = '' + for movie in movies: + number = movie.movies_number + if movie.movies_o_title: + original_title = movie.movies_o_title.encode(defaultEnc) + else: + original_title = '' + if movie.movies_title: + title = movie.movies_title.encode(defaultEnc) + else: + title = '' + grouping_title = movie.movies_title + if grouping_title is None: + grouping_title = u'None' + if movie.movies_director: + director = ' - ' + movie.movies_director.encode(defaultEnc) + else: + director = "" + # group by first letter + # use movie.title/grouping_title for grouping because of encoding problems !!! + if do_grouping and grouping_title[0] != first_letter: + if grouping_title[0] in '0123456789': + # Group Numbers + if first_letter != '0-9': + first_letter = '0-9' + paragraph_text = saxutils.escape(first_letter) + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Heading2']) + Story.append(p) + else: + first_letter = grouping_title[0] paragraph_text = saxutils.escape(first_letter) p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Heading2']) Story.append(p) - else: - first_letter = grouping_title[0] - paragraph_text = saxutils.escape(first_letter) - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Heading2']) - Story.append(p) - # add movie title - paragraph_text = ''+ saxutils.escape(title) + '' + \ - saxutils.escape(' (' + original_title + ') | ' + str(number)) - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Heading3']) - if 'image' in pdf_elements: - image_filename = None - if movie.poster_md5: - image_filename = gutils.get_image_fname(movie.poster_md5, self.db, 'm') - if image_filename: - p = ParagraphAndImage(p, Image(image_filename, width = 30, height = 40), side = 'left') - # wrap call needed because of a bug in reportlab flowables.py - ParagraphAndImage::split(self,availWidth, availHeight) - # AttributeError: ParagraphAndImage instance has no attribute 'wI' - p.wrap(30, 40) - Story.append(p) - if 'year' in pdf_elements and movie.year: - paragraph_text = '' + _('Year') + ': ' + saxutils.escape(str(movie.year)) - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) - Story.append(p) - if 'runtime' in pdf_elements and movie.runtime: - paragraph_text = '' + _('Runtime') + ': ' + saxutils.escape(str(movie.runtime)) - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) - Story.append(p) - if 'genre' in pdf_elements and movie.genre: - paragraph_text = '' + _('Genre') + ': ' + saxutils.escape(movie.genre.encode(defaultEnc)) - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) - Story.append(p) - if 'director' in pdf_elements and movie.director: - paragraph_text = '' + _('Director') + ': ' + saxutils.escape(movie.director.encode(defaultEnc)) + '' - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) - Story.append(p) - if 'cast' in pdf_elements and movie.cast: - paragraph_text = '' + _('Cast') + ': ' + saxutils.escape('; '.join(movie.cast.encode(defaultEnc).split("\n")[0:2])) + '' - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + # add movie title + paragraph_text = ''+ saxutils.escape(title) + '' + \ + saxutils.escape(' (' + original_title + ') | ' + str(number)) + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Heading3']) + if 'image' in pdf_elements: + image_filename = None + if movie.movies_poster_md5: + image_filename = gutils.get_image_fname(movie.movies_poster_md5, self.db, 'm') + if image_filename: + p = ParagraphAndImage(p, Image(image_filename, width = 30, height = 40), side = 'left') + # wrap call needed because of a bug in reportlab flowables.py - ParagraphAndImage::split(self,availWidth, availHeight) + # AttributeError: ParagraphAndImage instance has no attribute 'wI' + p.wrap(30, 40) Story.append(p) - if 'plot' in pdf_elements and movie.plot: - paragraph_text = '' + _('Plot') + ': ' + saxutils.escape(movie.plot.encode(defaultEnc)) + '' - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) - Story.append(p) - if 'notes' in pdf_elements and movie.notes: - paragraph_text = '' + _('Notes') + ': ' + saxutils.escape(movie.notes.encode(defaultEnc)) + '' - p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) - Story.append(p) - c.build(Story, onFirstPage=self.page_template, onLaterPages=self.page_template) - gutils.info(_('PDF has been created.'), self.parent_window) + if 'year' in pdf_elements and movie.movies_year: + paragraph_text = '' + _('Year') + ': ' + saxutils.escape(str(movie.movies_year)) + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if 'runtime' in pdf_elements and movie.movies_runtime: + paragraph_text = '' + _('Runtime') + ': ' + saxutils.escape(str(movie.movies_runtime)) + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if 'genre' in pdf_elements and movie.movies_genre: + paragraph_text = '' + _('Genre') + ': ' + saxutils.escape(movie.movies_genre.encode(defaultEnc)) + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if 'director' in pdf_elements and movie.movies_director: + paragraph_text = '' + _('Director') + ': ' + saxutils.escape(movie.movies_director.encode(defaultEnc)) + '' + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if 'cast' in pdf_elements and movie.movies_cast: + paragraph_text = '' + _('Cast') + ': ' + saxutils.escape('; '.join(movie.movies_cast.encode(defaultEnc).split("\n")[0:2])) + '' + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if 'plot' in pdf_elements and movie.movies_plot: + paragraph_text = '' + _('Plot') + ': ' + saxutils.escape(movie.movies_plot.encode(defaultEnc)) + '' + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if 'notes' in pdf_elements and movie.movies_notes: + paragraph_text = '' + _('Notes') + ': ' + saxutils.escape(movie.movies_notes.encode(defaultEnc)) + '' + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + resolution = self._get_resolution(movie) + if resolution: + paragraph_text = '' + _('Resolution') + ': ' + saxutils.escape(resolution.encode(defaultEnc)) + '' + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if movie.volumes_name: + paragraph_text = '' + _('Volume') + ': ' + saxutils.escape(movie.volumes_name.encode(defaultEnc)) + '' + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + if movie.collections_name: + paragraph_text = '' + _('Collection') + ': ' + saxutils.escape(movie.collections_name.encode(defaultEnc)) + '' + p = Paragraph(paragraph_text.decode(defaultEnc), self.styles['Normal']) + Story.append(p) + c.build(Story, onFirstPage=self.page_template, onLaterPages=self.page_template) + gutils.info(_('PDF has been created.'), self.parent_window) + except Exception, e: + log.exception('') + gutils.error(str(e)) def create_styles(self): self.styles = getSampleStyleSheet() @@ -206,18 +238,23 @@ fontfilename = self.config.get('font', '') (fontfilenamebase, fontfilenameextension) = os.path.splitext(fontfilename) - pdfmetrics.registerFont(TTFont(self.fontName, fontfilename)) - addMapping(self.fontName, 0, 0, self.fontName) - # build font family if available to support and - if os.path.isfile(fontfilenamebase + 'bd' + fontfilenameextension): - pdfmetrics.registerFont(TTFont(self.fontName + '-bold', fontfilenamebase + 'bd' + fontfilenameextension)) - addMapping(self.fontName, 1, 0, self.fontName + '-bold') - if os.path.isfile(fontfilenamebase + 'bi' + fontfilenameextension): - pdfmetrics.registerFont(TTFont(self.fontName + '-bolditalic', fontfilenamebase + 'bi' + fontfilenameextension)) - addMapping(self.fontName, 1, 1, self.fontName + '-bolditalic') - if os.path.isfile(fontfilenamebase + 'i' + fontfilenameextension): - pdfmetrics.registerFont(TTFont(self.fontName + '-italic', fontfilenamebase + 'i' + fontfilenameextension)) - addMapping(self.fontName, 0, 1, self.fontName + '-italic') + try: + pdfmetrics.registerFont(TTFont(self.fontName, fontfilename)) + except: + log.exception('') + self.fontName = "Helvetica" + else: + addMapping(self.fontName, 0, 0, self.fontName) + # build font family if available to support and + if os.path.isfile(fontfilenamebase + 'bd' + fontfilenameextension): + pdfmetrics.registerFont(TTFont(self.fontName + '-bold', fontfilenamebase + 'bd' + fontfilenameextension)) + addMapping(self.fontName, 1, 0, self.fontName + '-bold') + if os.path.isfile(fontfilenamebase + 'bi' + fontfilenameextension): + pdfmetrics.registerFont(TTFont(self.fontName + '-bolditalic', fontfilenamebase + 'bi' + fontfilenameextension)) + addMapping(self.fontName, 1, 1, self.fontName + '-bolditalic') + if os.path.isfile(fontfilenamebase + 'i' + fontfilenameextension): + pdfmetrics.registerFont(TTFont(self.fontName + '-italic', fontfilenamebase + 'i' + fontfilenameextension)) + addMapping(self.fontName, 0, 1, self.fontName + '-italic') else: self.fontName = "Helvetica" diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/extensions/ge_movieposterdb.py trunk/lib/plugins/extensions/ge_movieposterdb.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/extensions/ge_movieposterdb.py 2011-08-11 22:35:36.000000000 +0300 +++ trunk/lib/plugins/extensions/ge_movieposterdb.py 2013-07-27 18:37:05.103522449 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: ge_movieposterdb.py 1568 2011-08-10 20:08:12Z mikej06 $' +__revision__ = '$Id: ge_movieposterdb.py 1624 2012-06-07 19:07:22Z mikej06 $' # Copyright © 2010 Michael Jahn # @@ -77,23 +77,23 @@ if movie.year: url = self.baseurltitleyear % (o_title, movie.year) data = self._get(url, self.widgets['window']) - if data: + if data and data.find('movie/0000000') < 0: largeurl = gutils.trim(data, 'src=\\"', '\\"').replace('/t_', '/l_') if not data or not largeurl: url = self.baseurltitle % o_title data = self._get(url, self.widgets['window']) - if data: + if data and data.find('movie/0000000') < 0: largeurl = gutils.trim(data, 'src=\\"', '\\"').replace('/t_', '/l_') if not data or not largeurl and title and title != o_title: if movie.year: url = self.baseurltitleyear % (title, movie.year) data = self._get(url, self.widgets['window']) - if data: + if data and data.find('movie/0000000') < 0: largeurl = gutils.trim(data, 'src=\\"', '\\"').replace('/t_', '/l_') if not data or not largeurl: url = self.baseurltitle % title data = self._get(url, self.widgets['window']) - if data: + if data and data.find('movie/0000000') < 0: largeurl = gutils.trim(data, 'src=\\"', '\\"').replace('/t_', '/l_') except: log.exception('') diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/imp/DVDProfiler.py trunk/lib/plugins/imp/DVDProfiler.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/imp/DVDProfiler.py 2011-12-19 00:35:26.000000000 +0200 +++ trunk/lib/plugins/imp/DVDProfiler.py 2013-07-27 18:37:06.030229996 +0300 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -__revision__ = '$Id: DVDProfiler.py 1605 2011-12-18 22:35:25Z piotrek $' +__revision__ = '$Id: DVDProfiler.py 1612 2012-01-02 21:14:32Z mikej06 $' # Copyright (c) 2009 @@ -205,11 +205,11 @@ details['screenplay'] = details['screenplay'] + lastName + ', ' elif firstName: details['screenplay'] = details['screenplay'] + firstName + ', ' - if len(details['director']) > 2: + if len(details['director']) > 1: details['director'] = details['director'][:-2] - if len(details['cameraman']) > 2: + if len(details['cameraman']) > 1: details['cameraman'] = details['cameraman'][:-2] - if len(details['screenplay']) > 2: + if len(details['screenplay']) > 1: details['screenplay'] = details['screenplay'][:-2] elif node.nodeName == 'Actors': details['cast'] = '' @@ -260,7 +260,7 @@ for genreElement in genreElements: if len(genreElement.childNodes) > 0: details['genre'] = details['genre'] + genreElement.childNodes[0].data.strip() + ', ' - if details['genre'] > 2: + if len(details['genre']) > 1: details['genre'] = details['genre'][:-2] elif node.nodeName == 'Studios': details['studio'] = '' @@ -268,7 +268,7 @@ for studioElement in studioElements: if len(studioElement.childNodes) > 0: details['studio'] = details['studio'] + studioElement.childNodes[0].data.strip() + ', ' - if details['studio'] > 2: + if len(details['studio']) > 1: details['studio'] = details['studio'][:-2] elif node.nodeName == 'Regions': regionElements = node.getElementsByTagName('Region') Only in trunk/lib/plugins/imp: Tellico.py diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/imp/__init__.py trunk/lib/plugins/imp/__init__.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/imp/__init__.py 2011-01-18 12:25:50.000000000 +0200 +++ trunk/lib/plugins/imp/__init__.py 2013-07-27 18:37:06.026896516 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: __init__.py 1497 2011-01-16 13:09:52Z mikej06 $' +__revision__ = '$Id: __init__.py 1628 2012-08-30 21:23:02Z mikej06 $' # Copyright (c) 2006-2011 Piotr Ożarowski # @@ -181,14 +181,11 @@ tags = details.pop('tags') else: tags = None + poster = None if 'poster' in details: poster = details.pop('poster') - else: - poster = None - if 'image' in details: + elif 'image' in details: poster = details.pop('image') - else: - poster = None try: # optional: do mapping of lookup data if not self.foreignkeymaps: @@ -229,6 +226,7 @@ db.tables.movie_tag.insert(bind=self.db.session.bind).execute({'movie_id': movie.lastrowid, 'tag_id': tag_id}) except: pass + self.db.session.commit() # adding poster if poster: if len(poster) > 4: diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAllRovi.py trunk/lib/plugins/movie/PluginMovieAllRovi.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAllRovi.py 2011-12-19 00:35:26.000000000 +0200 +++ trunk/lib/plugins/movie/PluginMovieAllRovi.py 2013-07-27 18:37:05.690214997 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: PluginMovieAllRovi.py 1605 2011-12-18 22:35:25Z piotrek $' +__revision__ = '$Id: PluginMovieAllRovi.py 1633 2012-12-28 23:11:42Z mikej06 $' # Copyright (c) 2009-2011 # @@ -151,7 +151,7 @@ # dict { movie_id -> [ expected result count for original url, expected result count for translated url ] } # test_configuration = { - 'Rocky' : [ 57, 57 ], + 'Rocky' : [ 100, 100 ], } class PluginTest: @@ -195,7 +195,7 @@ 'country' : 'USA', 'genre' : 'Drama', 'classification' : False, - 'studio' : 'Columbia Pictures, MGM, Revolution Studios, Chartoff Winkler Productions', + 'studio' : 'Chartoff Winkler Productions, Columbia Pictures, MGM, Revolution Studios', 'o_site' : False, 'site' : 'http://www.allrovi.com/movies/movie/rocky-balboa-v337682', 'trailer' : False, diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAllocine.py trunk/lib/plugins/movie/PluginMovieAllocine.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAllocine.py 2011-09-04 23:51:29.000000000 +0300 +++ trunk/lib/plugins/movie/PluginMovieAllocine.py 2013-07-27 18:37:05.670214115 +0300 @@ -1,8 +1,8 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: PluginMovieIMDB.py 176 2006-02-01 12:07:26Z iznogoud $' +__revision__ = '$Id: PluginMovieAllocine.py 1647 2013-05-24 21:16:22Z mikej06 $' -# Copyright (c) 2005-2011 Vasco Nunes, Piotr Ozarowski +# Copyright (c) 2005-2012 Vasco Nunes, Piotr Ozarowski # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,6 +21,11 @@ # You may use and distribute this software under the terms of the # GNU General Public License, version 2 or later +from datetime import date +import hashlib +import base64 +import string +import urllib import movie try: import simplejson as json @@ -35,15 +40,24 @@ plugin_language = _("French") plugin_author = "Pierre-Luc Levy, Michael Jahn (JSON api)" plugin_author_email = "" -plugin_version = "1.0" +plugin_version = "1.2" class Plugin(movie.Movie): def __init__(self, id): self.movie_id = id - self.url = "http://api.allocine.fr/xml/movie?partner=3&json=1&profile=large&code=%s" % str(self.movie_id) + self.query = "partner=100043982026&format=json&profile=large&code=%s" % str(self.movie_id) + self.url = "http://api.allocine.fr/rest/v3/movie?" self.encode = 'utf-8' + self.useurllib2 = True + def open_page(self, parent_window=None, url=None): + query = self.query + '&sed=' + date.today().strftime("%Y%m%d") + to_signature = '29d185d98c984a359e6e6f26a0474269' + query + signature = urllib.quote_plus(base64.b64encode(hashlib.sha1(to_signature).digest())) + url = self.url + query + '&sig=' + signature + return movie.Movie.open_page(self, parent_window, url) + def initialize(self): self.movie = json.JSONDecoder().decode(self.page)['movie'] @@ -101,14 +115,14 @@ if 'code' in activity: if activity['code'] == 8001: if 'role' in cast: - self.cast = self.cast + cast['person']['$'] + _(' as ') + cast['role'] + '\n' + self.cast = self.cast + cast['person']['name'] + _(' as ') + cast['role'] + '\n' else: - self.cast = self.cast + cast['person']['$'] + '\n' + self.cast = self.cast + cast['person']['name'] + '\n' def get_classification(self): self.classification = "" if 'movieCertificate' in self.movie: - self.classification = self.movie['movieCertificate']['$'] + self.classification = self.movie['movieCertificate']['certificate']['$'] def get_studio(self): self.studio = "" @@ -159,7 +173,7 @@ activity = cast['activity'] if 'code' in activity: if activity['code'] == code: - result = result + cast['person']['$'] + ', ' + result = result + cast['person']['name'] + ', ' if result: result = result[:-2] return result @@ -168,12 +182,22 @@ class SearchPlugin(movie.SearchMovie): def __init__(self): - self.original_url_search = "http://api.allocine.fr/xml/search?partner=3&json=1&count=100&profile=small&q=" - self.translated_url_search = "http://api.allocine.fr/xml/search?partner=3&json=1&count=100&profile=small&q=" + self.search_query = "partner=100043982026&format=json&q=%s&filter=movie&count=100&page=1&profile=small" + self.search_url = "http://api.allocine.fr/rest/v3/search?" + + self.original_url_search = "http://api.allocine.fr/rest/v3/search?partner=YW5kcm9pZC12M3M&count=100&profile=small&format=json&filter=movie&q=" + self.translated_url_search = "http://api.allocine.fr/rest/v3/search?partner=YW5kcm9pZC12M3M&count=100&profile=small&format=json&filter=movie&q=" self.encode = 'utf-8' self.remove_accents = True + self.useurllib2 = True def search(self, parent_window): + query = string.replace(self.search_query % self.title, ' ', '%20') + query = query + '&sed=' + date.today().strftime("%Y%m%d") + to_signature = '29d185d98c984a359e6e6f26a0474269' + query + signature = urllib.quote_plus(base64.b64encode(hashlib.sha1(to_signature).digest())) + self.title = self.search_url + query + '&sig=' + signature + self.url = '' if not self.open_search(parent_window): return None return self.page @@ -198,6 +222,7 @@ log.exception('') except: log.exception('') + log.error(self.page) # @@ -258,7 +283,7 @@ 'o_title' : u'Terminator, The', 'director' : u'James Cameron', 'plot' : True, - 'cast' : u'Arnold Schwarzenegger' + _(' as ') + 'le Terminator\n\ + 'cast' : u'Arnold Schwarzenegger' + _(' as ') + 'Le Terminator\n\ Michael Biehn' + _(' as ') + 'Kyle Reese\n\ Linda Hamilton' + _(' as ') + 'Sarah Connor\n\ Lance Henriksen' + _(' as ') + 'l\'inspecteur Vukovich\n\ @@ -268,7 +293,7 @@ Earl Boen' + _(' as ') + 'le Dr Peter Silberman\n\ Dick Miller' + _(' as ') + 'le marchand d\'armes\n\ Shawn Schepps' + _(' as ') + 'Nancy\n\ -Bill Paxton' + _(' as ') + 'le chef des punks\n\ +Bill Paxton' + _(' as ') + 'Le chef des punks\n\ Brian Thompson' + _(' as ') + 'un punk\n\ Marianne Muellerleile' + _(' as ') + 'la \'mauvaise\' Sarah Connor\n\ Franco Columbu' + _(' as ') + 'le Terminator infiltrant le bunker dans le futur\n\ @@ -306,7 +331,7 @@ 'notes' : False, 'runtime' : 108, 'image' : True, - 'rating' : 8, + 'rating' : 7, 'cameraman' : u'Adam Greenberg', 'screenplay' : u'James Cameron, Gale Anne Hurd, Harlan Ellison, William Wisher', 'barcode' : False diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAmazon.py trunk/lib/plugins/movie/PluginMovieAmazon.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAmazon.py 2011-12-04 17:59:11.000000000 +0200 +++ trunk/lib/plugins/movie/PluginMovieAmazon.py 2013-07-27 18:37:05.670214115 +0300 @@ -1,8 +1,8 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id$' +__revision__ = '$Id: PluginMovieAmazon.py 1633 2012-12-28 23:11:42Z mikej06 $' -# Copyright (c) 2006-2009 +# Copyright (c) 2006-2012 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -125,7 +125,9 @@ if hasattr(self.page.EditorialReviews, 'EditorialReview'): if isSequenceType(self.page.EditorialReviews.EditorialReview): for review in self.page.EditorialReviews.EditorialReview: - if string.find(review.Source, 'Amazon') > -1: + if hasattr(review, 'Source') and \ + hasattr(review, 'Content') and \ + string.find(review.Source, 'Amazon') > -1: self.plot = review.Content else: if hasattr(self.page.EditorialReviews.EditorialReview, 'Source') and \ @@ -398,8 +400,8 @@ # dict { movie_id -> [ expected result count for original url, expected result count for translated url ] } # test_configuration = { - 'Rocky Balboa' : [ 22, 22 ], - 'Arahan' : [ 9, 9 ], + 'Rocky Balboa' : [ 23, 23 ], + 'Arahan' : [ 10, 10 ], 'Glück' : [ 100, 100 ] } @@ -428,11 +430,11 @@ 'o_site' : False, 'site' : 'http://www.amazon.de/dp/B000TIQMMI', 'trailer' : False, - 'year' : 2006, + 'year' : 2007, 'notes' : 'EAN: 4045167004504', 'runtime' : 97, 'image' : True, - 'rating' : 8, + 'rating' : False, 'barcode' : '4045167004504' }, 'B0009NSASM' : { @@ -450,11 +452,11 @@ 'o_site' : False, 'site' : 'http://www.amazon.de/dp/B0009NSASM', 'trailer' : False, - 'year' : 1973, + 'year' : 2008, 'notes' : 'EAN: 7321921998843', 'runtime' : 110, 'image' : True, - 'rating' : 10, + 'rating' : False, 'barcode' : '7321921998843' }, 'B000BSNOD6' : { @@ -475,7 +477,7 @@ 'notes' : 'EAN: 4013549871105', 'runtime' : 108, 'image' : True, - 'rating' : 8, + 'rating' : False, 'barcode' : '4013549871105' } } diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAniDB.py trunk/lib/plugins/movie/PluginMovieAniDB.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieAniDB.py 2011-09-26 22:36:40.000000000 +0300 +++ trunk/lib/plugins/movie/PluginMovieAniDB.py 2013-07-27 18:37:05.666880634 +0300 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -__revision__ = '$Id: PluginMovieAniDB.py 1594 2011-09-22 21:00:44Z mikej06 $' +__revision__ = '$Id: PluginMovieAniDB.py 1633 2012-12-28 23:11:42Z mikej06 $' # Copyright © 2005-2011 Piotr Ożarowski # @@ -256,7 +256,7 @@ [Seras Victoria] voiced by Orikasa Fumiko\n\ [Incognito] voiced by Yamazaki Takumi', 'country' : False, - 'genre' : 'Law and Order, Alternative Present, Horror, Vampires, Gunfights, Action, Contemporary Fantasy, United Kingdom, Earth, Europe, Special Squads, Cops, Manga, Seinen, Violence, Fantasy, Present', + 'genre' : 'Law and Order, Alternative Present, Horror, Vampires, Gunfights, Action, Contemporary Fantasy, United Kingdom, Earth, Europe, Special Squads, Cops, Manga, Seinen, Violence, Fantasy, Present, London, Zombies', 'classification' : False, 'studio' : False, 'o_site' : 'http://www.gonzo.co.jp/works/0102.html', @@ -266,7 +266,7 @@ 'notes' : True, 'runtime' : 0, 'image' : True, - 'rating' : 8, + 'rating' : 6, 'cameraman' : False, 'screenplay' : False }, diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieCSFD.py trunk/lib/plugins/movie/PluginMovieCSFD.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieCSFD.py 2011-12-04 17:59:11.000000000 +0200 +++ trunk/lib/plugins/movie/PluginMovieCSFD.py 2013-07-27 18:37:05.670214115 +0300 @@ -214,7 +214,7 @@ # test_configuration = { 'Cliffhanger' : [ 1, 1 ], - 'Rocky' : [ 38, 38 ] + 'Rocky' : [ 41, 41 ] } @@ -245,10 +245,10 @@ Michael Ahl\n\ Dean Maur', 'country' : 'USA', - 'genre' : 'Sportovní / Drama', + 'genre' : 'Sportovní / Drama / Akční / Romantický', 'classification' : False, 'studio' : False, - 'o_site' : 'http://www.mgm.com/view/movie/1667/Rocky-Balboa/', + 'o_site' : False, 'site' : 'http://www.imdb.com/title/tt0479143/', 'trailer' : 'http://www.csfd.cz/film/221900-rocky-balboa/videa', 'year' : 2006, @@ -275,11 +275,13 @@ Gregory Scott Cummins\n\ Max Perlich\n\ Paul Winfield\n\ +Ralph Waite\n\ Zach Grenier\n\ Don S. Davis\n\ Bruce McGill\n\ Jeff Blynn\n\ -John Fin', +John Finn\n\ +Rosemary Dunsmor', 'country' : 'USA / Itálie / Francie', 'genre' : 'Akční / Dobrodružný / Thriller', 'classification' : False, diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieCineMovies.py trunk/lib/plugins/movie/PluginMovieCineMovies.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieCineMovies.py 2011-08-31 09:40:41.000000000 +0300 +++ trunk/lib/plugins/movie/PluginMovieCineMovies.py 2013-07-27 18:37:05.673547595 +0300 @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -__revision__ = '$Id: PluginMovieCineMovies.py 1577 2011-08-30 21:13:26Z mikej06 $' +__revision__ = '$Id: PluginMovieCineMovies.py 1644 2013-02-21 20:37:27Z mikej06 $' # Copyright (c) 2005-2011 Vasco Nunes, Piotr Ożarowski # @@ -30,66 +30,64 @@ plugin_language = _("French") plugin_author = "Vasco Nunes" plugin_author_email = "" -plugin_version = "0.4" +plugin_version = "0.5" class Plugin(movie.Movie): def __init__(self, id): - self.encode = 'iso-8859-1' + self.encode = 'utf-8' self.movie_id = id - self.url = "http://www.cinemovies.fr/fiche_film.php?IDfilm=" + str(self.movie_id) - - def initialize(self): - self.page_cast = self.open_page(self.parent_window, url = 'http://www.cinemovies.fr/fiche_cast.php?IDfilm='+ str(self.movie_id)) + self.url = "http://www.cinemovies.fr/film/" + str(self.movie_id) + print self.url def get_image(self): - self.image_url = gutils.trim(self.page, '') + self.image_url = gutils.trim(gutils.trim(self.page, 'property="og:image"', '>'), '"', '"') def get_o_title(self): - self.o_title = gutils.trim(self.page, 'Titre original :', '') + self.o_title = gutils.trim(self.page, 'Titre original :', '') def get_title(self): - self.title = gutils.trim(self.page, '

', '

') + self.title = gutils.trim(gutils.trim(self.page, 'property="og:title"', '>'), '"', '"') def get_director(self): - self.director = gutils.clean(gutils.trim(self.page_cast, u'Réalisé par :', '
')) + self.director = gutils.clean(gutils.trim(self.page, u'Réalisé par', '')) self.director = re.sub('[\n|\t]+', ', ', self.director) def get_plot(self): - self.plot = gutils.trim(gutils.after(self.page, '>L\'histoire<'), '
', '
') + self.plot = gutils.after(gutils.trim(self.page, 'class="synopsis"', '
'), '>') def get_year(self): - self.year = gutils.trim(self.page, 'Date(s) de Sortie(s)', '') - if len(self.year) > 4: - self.year = self.year[len(self.year) - 4:len(self.year)] + self.year = gutils.trim(gutils.trim(self.page, 'Date de sortie :', ''), 'content="', '-') def get_runtime(self): - self.runtime = gutils.clean(gutils.trim(self.page, u'>Durée :', '')) + self.runtime = gutils.clean(gutils.trim(self.page, u'Durée : ', '')) if self.runtime: - if self.runtime.find('h') > 0: - self.runtime = str (int(gutils.before(self.runtime,'h'))*60 + int(gutils.after(self.runtime,'h'))) + if self.runtime.find('H') > 0: + self.runtime = str (int(gutils.before(self.runtime,'H'))*60 + int(gutils.after(self.runtime,'H'))) else: self.runtime = gutils.before(self.runtime,' mn') def get_genre(self): - self.genre = gutils.trim(self.page, 'Genre :', '') + self.genre = gutils.trim(self.page, 'Genre :', '') self.genre = re.sub('[,][^,]*$', '', self.genre) self.genre = self.genre.replace(',', ', ') def get_cast(self): - self.cast = gutils.trim(self.page_cast, u'Comédiens :', '
') - self.cast = self.cast.replace('\n', '') - self.cast = self.cast.replace('', '\n') - self.cast = re.sub('', _(' as '), self.cast) - self.cast = gutils.clean(self.cast) - self.cast = re.sub(_(' as ') + '[ \t]*(\n|$)', '\n', self.cast) - self.cast = re.sub('[ \t]*\n[ \t]+', '\n', self.cast) + self.cast = '' + tmp = self.page.split('itemprop="actor"') + for element in tmp[1:]: + actor = gutils.trim(element, '>', '') + role = gutils.after(gutils.trim(element, u'Rôle', ''), ': ') + if role: + self.cast = self.cast + actor + _(' as ') + role + '\n' + else: + self.cast = self.cast + actor + '\n' def get_classification(self): # not available on this site self.classification = '' def get_studio(self): - self.studio = string.strip(gutils.trim(self.page, 'Distributeur :', '')) + self.studio = string.strip(gutils.trim(self.page, 'Distributeur :', '')) def get_o_site(self): self.o_site = gutils.after(gutils.after(gutils.trim(self.page, '>Site(s) Officiel(s)<', '') @@ -108,35 +106,33 @@ self.rating = gutils.clean(gutils.trim(self.page, '
', '
')) def get_screenplay(self): - self.screenplay = gutils.clean(gutils.trim(self.page_cast, u'Scénario de :', '
')) + self.screenplay = gutils.clean(gutils.trim(self.page, u'Scénario de :', '
')) self.screenplay = re.sub('[\n|\t]+', ', ', self.screenplay) class SearchPlugin(movie.SearchMovie): def __init__(self): - self.encode = 'iso-8859-1' - self.original_url_search = "http://www.cinemovies.fr/resultat_recherche.php?typsearch=11&cherche=" - self.translated_url_search = "http://www.cinemovies.fr/resultat_recherche.php?typsearch=11&cherche=" + self.encode = 'utf-8' + self.original_url_search = 'http://www.cinemovies.fr/rechercher/?e=m&page=1&q=' + self.translated_url_search = 'http://www.cinemovies.fr/rechercher/?e=m&page=1&q=' def search(self,parent_window): if not self.open_search(parent_window): return None - self.sub_search() return self.page - def sub_search(self): - self.page = gutils.trim(self.page, '
Les film', '
') - def get_searches(self): - elements = string.split(self.page, ''), '>'))) - year = gutils.after(gutils.trim(element, ''), '>') - self.titles.append(title + ' (' + year + ')') + id = gutils.before(element, '"') + title = gutils.clean(gutils.trim(element, '>', '<')) + if id and title: + self.ids.append(id) + year = gutils.trim(element, '">Sortie le', '<') + self.titles.append(title + ' (' + year + ')') else: self.number_results = 0 @@ -149,7 +145,7 @@ # dict { movie_id -> [ expected result count for original url, expected result count for translated url ] } # test_configuration = { - 'Rocky Balboa' : [ 2, 2 ], + 'Rocky Balboa' : [ 4, 4 ], } class PluginTest: @@ -161,7 +157,7 @@ # * or the expected value # test_configuration = { - '6065' : { + 'rocky-balboa_e54849' : { 'title' : 'Rocky Balboa', 'o_title' : 'Rocky VI', 'director' : 'Sylvester Stallone', @@ -186,7 +182,7 @@ 'classification' : False, 'studio' : 'Twentieth Century Fox France', 'o_site' : 'http://www.sonypictures.com/movies/rocky/', - 'site' : 'http://www.cinemovies.fr/fiche_film.php?IDfilm=6065', + 'site' : 'http://www.cinemovies.fr/film/rocky-balboa_e54849', 'trailer' : 'http://www.cinemovies.fr/fiche_multimedia.php?IDfilm=6065', 'year' : 2007, 'notes' : False, diff -ur -x .svn -x .git -x .bzr -x CVS -x AUTHORS -x ChangeLog ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieCineteka.py trunk/lib/plugins/movie/PluginMovieCineteka.py --- ../BUILD.i686-linux/griffith-0.13/lib/plugins/movie/PluginMovieCineteka.py 2011-08-31 09:40:41.000000000 +0300 +++ trunk/lib/plugins/movie/PluginMovieCineteka.py 2013-07-27 18:37:05.676881075 +0300 @@ -134,7 +134,7 @@ class SearchPlugin(movie.SearchMovie): """A movie search object""" def __init__(self): - self.original_url_search = "http://www.cineteka.com/index.php?op=MovieSearch&s=" + self.original_url_search = "http://www.cineteka.com/index.php?op=MovieSearch&perfil_display=0&ordby=3&s=" self.translated_url_search = self.original_url_search self.encode = 'iso-8859-1' @@ -142,7 +142,7 @@ """Perform the web search""" if not self.open_search(parent_window): return None - self.page = gutils.trim(self.page, 'tulo(s): ', '