def run(self): prefs = Utility.loadPrefs(Globals.options).get(PLUGIN_NAME) if prefs is not None: license = prefs.get('license') if license: setLicense(license) return False # no need to run again
def run_search(self): self.result = [] try: amazon.setLicense('04GDDMMXX8X9CJ1B22G2') try: tmp = amazon.searchByTitle(self.title, type='ItemAttributes', product_line='Video', locale=self.locale, page=1) self.result.append(tmp) if hasattr(tmp, 'TotalPages'): pages = int(tmp.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByTitle(self.title, type='ItemAttributes', product_line='Video', locale=self.locale, page=page) self.result.append(tmp) page = page + 1 except amazon.AmazonError, e: log.error(e.Message) # if all digits then try to find an EAN / UPC if self.title.isdigit(): if len(self.title) == 13: try: tmp = amazon.searchByEAN(self.title, type='ItemAttributes', product_line='Video', locale=self.locale) self.result.append(tmp) except amazon.AmazonError, e: log.error(e.Message) elif len(self.title) == 12: try: tmp = amazon.searchByUPC(self.title, type='ItemAttributes', product_line='Video', locale=self.locale) self.result.append(tmp) except amazon.AmazonError, e: log.error(e.Message)
def fetch_bigger_poster(self): match = 0 self.debug.show("fetching poster from amazon") movie = self.db.Movie.get_by(movie_id=self._movie_id) if movie is None: gutils.error(self,_("You have no movies in your database"), self.widgets['window']) return False current_poster = movie.image amazon.setLicense("04GDDMMXX8X9CJ1B22G2") locale = self.config.get('amazon_locale', 0, section='add') keyword = self.widgets['movie']['o_title'].get_text().decode('utf-8') if locale == '1': locale = 'uk' elif locale == '2': locale = 'de' keyword = self.widgets['movie']['title'].get_text().decode('utf-8') elif locale == '3': locale = 'ca' elif locale == '4': locale = 'fr' elif locale == '5': locale = 'jp' else: locale = None try: result = amazon.searchByKeyword(keyword, type="Large", product_line="DVD", locale=locale) self.debug.show("Posters found on amazon: %s posters" % result.TotalResults) except: gutils.warning(self, _("No posters found for this movie.")) return from widgets import connect_poster_signals, reconnect_add_signals connect_poster_signals(self, get_poster_select_dc, result, current_poster) if not len(result.Item): gutils.warning(self, _("No posters found for this movie.")) reconnect_add_signals(self) return for f in range(len(result.Item)): if self.widgets['movie']['o_title'].get_text().decode('utf-8') == result.Item[f].ItemAttributes.Title: get_poster(self, f, result, current_poster) return self.treemodel_results.clear() self.widgets['add']['b_get_from_web'].set_sensitive(False) # disable movie plugins (result window is shared) for f in range(len(result.Item)): if hasattr(result.Item[f], "LargeImage") and len(result.Item[f].LargeImage.URL): title = result.Item[f].ItemAttributes.Title myiter = self.treemodel_results.insert_before(None, None) self.treemodel_results.set_value(myiter, 0, str(f)) self.treemodel_results.set_value(myiter, 1, title) self.widgets['results']['window'].show() self.widgets['results']['window'].set_keep_above(True)
def fetch_bigger_poster(self): match = 0 self.debug.show("fetching poster from amazon") movie = self.db.Movie.get_by(movie_id=self._movie_id) if movie is None: gutils.error(self, _("You have no movies in your database"), self.widgets["window"]) return False current_poster = movie.image amazon.setLicense("04GDDMMXX8X9CJ1B22G2") locale = self.config.get("amazon_locale", 0) if locale == 1: locale = "uk" elif locale == 2: locale = "de" elif locale == 3: locale = "uk" else: locale = None try: result = amazon.searchByKeyword( self.widgets["movie"]["o_title"].get_text(), type="lite", product_line="dvd", locale=locale ) self.debug.show("Posters found on amazon: %s posters" % len(result)) except: gutils.warning(self, _("No posters found for this movie.")) return from widgets import connect_poster_signals, reconnect_add_signals connect_poster_signals(self, get_poster_select_dc, result, current_poster) if not len(result): gutils.warning(self, _("No posters found for this movie.")) reconnect_add_signals(self) return for f in range(len(result)): if self.widgets["movie"]["o_title"].get_text() == result[f].ProductName: get_poster(self, f, result, current_poster) return self.treemodel_results.clear() self.widgets["add"]["b_get_from_web"].set_sensitive(False) # disable movie plugins (result window is shared) for f in range(len(result)): if len(result[f].ImageUrlLarge): title = result[f].ProductName myiter = self.treemodel_results.insert_before(None, None) self.treemodel_results.set_value(myiter, 0, str(f)) self.treemodel_results.set_value(myiter, 1, title) self.widgets["results"]["window"].show() self.widgets["results"]["window"].set_keep_above(True)
def run_get(self): self.result = None try: amazon.setLicense("04GDDMMXX8X9CJ1B22G2") # get by ASIN try: self.result = amazon.searchByASIN(self.title, type="Large", locale=self.locale) except amazon.AmazonError, e: self.debug.show(e.Message) except IOError: self.progress.dialog.hide() gutils.urllib_error(_("Connection error"), self.parent_window) self.suspend()
def configure(self, config): self.enabled = config["enabled"] self.minsize = config["minsize"] l = config["licensenumber"] # Override the old access key if l == "D1ESMA5AOEZB24": l = defaultConfig["licensenumber"] config["licensenumber"] = l if l and len(l): amazon.setLicense(l) l = config["locale"] if l and len(l): amazon.setLocale(l) l = config["proxy"] if l and len(l): amazon.setProxy(l)
def open_page(self, parent_window=None, url=None): # dont use base functionality # use the Amazon Web API self.parent_window = parent_window try: accesskey = self.config.get('amazon_accesskey', None, section='extensions') secretkey = self.config.get('amazon_secretkey', None, section='extensions') if not accesskey or not secretkey: gutils.error( _('Please configure your Amazon Access Key ID and Secret Key correctly in the preferences dialog.' )) return False amazon.setLicense(accesskey, secretkey) locale = self.config.get('amazon_locale', 0, section='extensions') if locale == '1' or locale == 'UK': locale = 'uk' elif locale == '2' or locale == 'DE': locale = 'de' elif locale == '3' or locale == 'CA': locale = 'ca' elif locale == '4' or locale == 'FR': locale = 'fr' elif locale == '5' or locale == 'JP': locale = 'jp' else: locale = None retriever = AmazonRetriever(self.movie_id, locale, parent_window, self.progress, 'Get') retriever.start() while retriever.isAlive(): self.progress.pulse() while gtk.events_pending(): gtk.main_iteration() self.page = retriever.result.Item[0] except: self.page = '' try: log.exception('Error retrieving results from amazon.') log.error(retriever.result.Request.Errors.Error.Message) except: pass return self.page
def open_page(self, parent_window=None, url=None): # dont use base functionality # use the Amazon Web API self.parent_window = parent_window try: accesskey = self.config.get("amazon_accesskey", None, section="extensions") secretkey = self.config.get("amazon_secretkey", None, section="extensions") if not accesskey or not secretkey: gutils.error( _("Please configure your Amazon Access Key ID and Secret Key correctly in the preferences dialog.") ) return False amazon.setLicense(accesskey, secretkey) locale = self.config.get("amazon_locale", 0, section="extensions") if locale == "1" or locale == "UK": locale = "uk" elif locale == "2" or locale == "DE": locale = "de" elif locale == "3" or locale == "CA": locale = "ca" elif locale == "4" or locale == "FR": locale = "fr" elif locale == "5" or locale == "JP": locale = "jp" else: locale = None retriever = AmazonRetriever(self.movie_id, locale, parent_window, self.progress, "Get") retriever.start() while retriever.isAlive(): self.progress.pulse() while gtk.events_pending(): gtk.main_iteration() self.page = retriever.result.Item[0] except: self.page = "" try: log.exception("Error retrieving results from amazon.") log.error(retriever.result.Request.Errors.Error.Message) except: pass return self.page
def open_page(self, parent_window=None, url=None): # dont use base functionality # use the Amazon Web API self.parent_window = parent_window try: accesskey = self.config.get('amazon_accesskey', None, section='extensions') secretkey = self.config.get('amazon_secretkey', None, section='extensions') if not accesskey or not secretkey: gutils.error(_('Please configure your Amazon Access Key ID and Secret Key correctly in the preferences dialog.')) return False amazon.setLicense(accesskey, secretkey) locale = self.config.get('amazon_locale', 0, section='extensions') if locale == '1' or locale == 'UK': locale = 'uk' elif locale == '2' or locale == 'DE': locale = 'de' elif locale == '3' or locale == 'CA': locale = 'ca' elif locale == '4' or locale == 'FR': locale = 'fr' elif locale == '5' or locale == 'JP': locale = 'jp' else: locale = None retriever = AmazonRetriever(self.movie_id, locale, parent_window, self.progress, 'Get') retriever.start() while retriever.isAlive(): self.progress.pulse() while gtk.events_pending(): gtk.main_iteration() self.page = retriever.result.Item[0] except: self.page = '' try: log.exception('Error retrieving results from amazon.') log.error(retriever.result.Request.Errors.Error.Message) except: pass return self.page
def fetch_bigger_poster(self): match = 0 self.debug.show("fetching poster from amazon") this_movie = self.db.select_movie_by_num(self.e_number.get_text()) current_poster = this_movie[0]['image'] amazon.setLicense("04GDDMMXX8X9CJ1B22G2") try: result = amazon.searchByKeyword(self.e_original_title.get_text(), \ type="lite", product_line="dvd") self.debug.show("Posters found on amazon: %s posters" % len(result)) except: gutils.warning(self, _("No posters found for this movie.")) return widgets.connect_poster_signals(self, get_poster_select_dc, result, current_poster) if not len(result): gutils.warning(self, _("No posters found for this movie.")) return for f in range(len(result)): if self.e_original_title.get_text() == result[f].ProductName: get_poster(self, f, result, current_poster) return self.treemodel_results.clear() for f in range(len(result)): if (len(result[f].ImageUrlLarge)): title = result[f].ProductName self.debug.show(title) myiter = self.treemodel_results.insert_before(None, None) self.treemodel_results.set_value(myiter, 0, str(f)) self.treemodel_results.set_value(myiter, 1, title) self.w_results.show() self.w_results.set_keep_above(True)
def promptLicense(): dialog = LicenseDialog(wx.GetApp().mainFrame, -1) dialog.CenterOnScreen() if dialog.ShowModal() == wx.ID_OK: params = dialog.getParameters() else: params = None dialog.Destroy() if params is not None: license = params['license'] if license: prefs = Utility.loadPrefs(Globals.options) pluginPrefs = prefs.setdefault(PLUGIN_NAME, {}) pluginPrefs['license'] = license prefs.write() setLicense(license) return True return False
def fetch_bigger_poster(self): match = 0 log.info("fetching poster from amazon...") movie = self.db.session.query(db.Movie).filter_by(movie_id=self._movie_id).first() if movie is None: gutils.error(self, _("You have no movies in your database"), self.widgets["window"]) return False current_poster_md5 = movie.poster_md5 if current_poster_md5: current_poster = gutils.get_image_fname(current_poster_md5, self.db) else: current_poster = None amazon.setLicense("04GDDMMXX8X9CJ1B22G2") locale = self.config.get("amazon_locale", 0, section="add") keyword = self.widgets["movie"]["o_title"].get_text() if locale == "1": locale = "uk" elif locale == "2": locale = "de" keyword = self.widgets["movie"]["title"].get_text() elif locale == "3": locale = "ca" elif locale == "4": locale = "fr" elif locale == "5": locale = "jp" else: locale = None try: result = amazon.searchByTitle(keyword, type="Large", product_line="DVD", locale=locale) if hasattr(result, "TotalPages"): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByTitle(keyword, type="Large", product_line="DVD", locale=locale, page=page) result.Item.extend(tmp.Item) page = page + 1 if not hasattr(result, "Item") or not len(result.Item): # fallback if nothing is found by title result = amazon.searchByKeyword(keyword, type="Large", product_line="DVD", locale=locale) if hasattr(result, "TotalPages"): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByKeyword(keyword, type="Large", product_line="DVD", locale=locale, page=page) result.Item.extend(tmp.Item) page = page + 1 log.info("... %s posters found" % result.TotalResults) except: gutils.warning(_("No posters found for this movie.")) return from widgets import connect_poster_signals, reconnect_add_signals connect_poster_signals(self, get_poster_select_dc, result, current_poster) if not hasattr(result, "Item") or not len(result.Item): gutils.warning(_("No posters found for this movie.")) reconnect_add_signals(self) return if len(result.Item) == 1: o_title = self.widgets["movie"]["o_title"].get_text().decode("utf-8") if o_title == result.Item[0].ItemAttributes.Title or keyword == result.Item[0].ItemAttributes.Title: get_poster(self, 0, result) return self.treemodel_results.clear() self.widgets["add"]["b_get_from_web"].set_sensitive(False) # disable movie plugins (result window is shared) for f in range(len(result.Item)): if hasattr(result.Item[f], "LargeImage") and len(result.Item[f].LargeImage.URL): title = result.Item[f].ItemAttributes.Title if hasattr(result.Item[f].ItemAttributes, "ProductGroup"): title = title + u" - " + result.Item[f].ItemAttributes.ProductGroup elif hasattr(result.Item[f].ItemAttributes, "Binding"): title = title + u" - " + result.Item[f].ItemAttributes.Binding if hasattr(result.Item[f].ItemAttributes, "ReleaseDate"): title = title + u" - " + result.Item[f].ItemAttributes.ReleaseDate[:4] elif hasattr(result.Item[f].ItemAttributes, "TheatricalReleaseDate"): result.Item[f].ItemAttributes.TheatricalReleaseDate[:4] if hasattr(result.Item[f].ItemAttributes, "Studio"): title = title + u" - " + result.Item[f].ItemAttributes.Studio myiter = self.treemodel_results.insert_before(None, None) self.treemodel_results.set_value(myiter, 0, str(f)) self.treemodel_results.set_value(myiter, 1, title) self.widgets["results"]["window"].show() self.widgets["results"]["window"].set_keep_above(True)
import sys, amazon # Display author's name nicely. def prettyName(arg): if type(arg) in (list, tuple): arg = ', '.join(arg[:-1]) + ' and ' + arg[-1] return arg if __name__ == '__main__': # Get information. key, asin = sys.argv[1], sys.argv[2] amazon.setLicense(key) items = amazon.searchByASIN(asin) # Display information. for item in items: productName = item.ProductName ourPrice = item.OurPrice authors = prettyName(item.Authors.Author) print '%s: %s (%s)' % (authors, productName, ourPrice)
def process_close (self, creq): close = zdefs.Close () close.closeReason = zdefs.CloseReason.get_num_from_name ( 'responseToPeer') self.send_PDU ('close', close) self.transport.loseConnection () if __name__ == '__main__': if 0: from PyZ3950 import z3950 print rpn_q_to_amazon ( ('type_1', z3950.mk_simple_query ('Among the gently mad'))) print rpn_q_to_amazon (('type_1', z3950.mk_compound_query ())) else: amazon.setLicense (amazon.getLicense ()) factory = protocol.Factory () factory.protocol = Z3950Server reactor.listenTCP (2100, factory) reactor.run ()
__parcel__ = "osaf.examples.amazon" import amazon import application from osaf.pim import ContentItem, ItemCollection import wx from application import schema amazon.setLicense('0X5N4AEK0PTPMZK1NNG2') def CreateCollection(repView, cpiaView): keywords = application.dialogs.Util.promptUser(wx.GetApp().mainFrame, "New Amazon Collection", "Enter your Amazon search keywords:", "Theodore Leung") newAmazonCollection = AmazonCollection(view=repView, keywords=keywords) return cpiaView.postEventByName('AddToSidebarWithoutCopying', {'items' : [newAmazonCollection]}) def CreateWishListCollection(repView, cpiaView): emailAddr = application.dialogs.Util.promptUser(wx.GetApp().mainFrame, "New Amazon Wish List", "What is the Amazon email address of the wish list?", "") newAmazonCollection = AmazonCollection(view=repView, email=emailAddr) return cpiaView.postEventByName('AddToSidebarWithoutCopying', {'items' : [newAmazonCollection]}) def NewCollectionFromKeywords(view, keywords, update = True): collection = AmazonCollection(keywords=keywords,view=view) if update: print "updating new amazon collection" return collection
def toolbar_icon_clicked(self, widget, movie): log.info("fetching poster from Amazon...") self.movie = movie locale = self.get_config_value("locale", "US").lower() accesskey = self.get_config_value("accesskey") secretkey = self.get_config_value("secretkey") if not accesskey or not secretkey: gutils.error( _("Please configure your Amazon Access Key ID and Secret Key correctly in the preferences dialog.") ) return False if movie is None: gutils.error(_("You have no movies in your database"), self.widgets["window"]) return False keyword = movie.o_title if locale == "de": keyword = movie.title try: amazon.setLicense(accesskey, secretkey) result = amazon.searchByTitle(keyword, type="Large", product_line="DVD", locale=locale) if hasattr(result, "TotalPages"): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByTitle(keyword, type="Large", product_line="DVD", locale=locale, page=page) result.Item.extend(tmp.Item) page = page + 1 if not hasattr(result, "Item") or not len(result.Item): # fallback if nothing is found by title result = amazon.searchByKeyword(keyword, type="Large", product_line="DVD", locale=locale) if hasattr(result, "TotalPages"): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByKeyword( keyword, type="Large", product_line="DVD", locale=locale, page=page ) result.Item.extend(tmp.Item) page = page + 1 self._result = result log.info("... %s posters found" % result.TotalResults) except: log.exception("") gutils.warning(_("No posters found for this movie.")) return if not hasattr(result, "Item") or not len(result.Item): gutils.warning(_("No posters found for this movie.")) return if len(result.Item) == 1: o_title = self.widgets["movie"]["o_title"].get_text().decode("utf-8") if o_title == result.Item[0].ItemAttributes.Title or keyword == result.Item[0].ItemAttributes.Title: self.get_poster(self.app, result.Item[0]) return # populate results window items = {} for i, item in enumerate(result.Item): if hasattr(item, "LargeImage") and len(item.LargeImage.URL): title = item.ItemAttributes.Title if hasattr(item.ItemAttributes, "ProductGroup"): title = title + u" - " + item.ItemAttributes.ProductGroup elif hasattr(item.ItemAttributes, "Binding"): title = title + u" - " + item.ItemAttributes.Binding if hasattr(item.ItemAttributes, "ReleaseDate"): title = title + u" - " + item.ItemAttributes.ReleaseDate[:4] elif hasattr(item.ItemAttributes, "TheatricalReleaseDate"): item.ItemAttributes.TheatricalReleaseDate[:4] if hasattr(item.ItemAttributes, "Studio"): title = title + u" - " + item.ItemAttributes.Studio items[i] = title populate_results_window(self.app.treemodel_results, items) self.widgets["add"]["b_get_from_web"].set_sensitive(False) # disable movie plugins (result window is shared) self.app._resultswin_process = ( self.on_result_selected ) # use this signal (will be reverted when window is closed) self.widgets["results"]["window"].show() self.widgets["results"]["window"].set_keep_above(True)
import amazon import urllib import gtk from optparse import OptionParser parser = OptionParser() parser.add_option("-m", "--mountpoint", dest="mountpoint", default="/mnt/ipod", help="use iPod at MOUNTPOINT", metavar="MOUNTPOINT") (options, args) = parser.parse_args() db = gpod.Database(options.mountpoint) # set your key here, or see amazon.py for a list of other places to # store it. amazon.setLicense('') images = {} for track in db: if track.get_coverart().thumbnails: #print " Already has artwork, skipping." # note we could remove it with track.set_coverart(None) continue print "%(artist)s, %(album)s, %(title)s" % track if not (track['artist'] and track['album']): print " Need an artist AND album name, skipping." continue
# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ################################################################################ import urllib, time import amazon amazon.setLicense('0XMTPCQ85ZMFF2PAT402') import mesk import mesk.plugin from mesk.i18n import _ from mesk.plugin.plugin import PluginInfo, Plugin from mesk.plugin.interfaces import MetaDataSearch def soundex(name, len=6): # digits holds the soundex values for the alphabet digits = '01230120022455012623010202' sndx = '' fc = '' # translate alpha chars in name to soundex digits
from optparse import OptionParser parser = OptionParser() parser.add_option("-m", "--mountpoint", dest="mountpoint", default="/mnt/ipod", help="use iPod at MOUNTPOINT", metavar="MOUNTPOINT") (options, args) = parser.parse_args() db = gpod.Database(options.mountpoint) # set your key here, or see amazon.py for a list of other places to # store it. amazon.setLicense('') images = {} for track in db: if track.get_coverart().thumbnails: #print " Already has artwork, skipping." # note we could remove it with track.set_coverart(None) continue print "%(artist)s, %(album)s, %(title)s" % track if not (track['artist'] and track['album']): print " Need an artist AND album name, skipping." continue
def set(self, s): # In case we decide we need to recover original = getattr(self, 'value', self._default) registry.String.set(self, s) if self.value: amazon.setLicense(self.value)
def fetch_bigger_poster(self): match = 0 log.info("fetching poster from amazon...") movie = self.db.session.query(db.Movie).filter_by(movie_id=self._movie_id).first() if movie is None: gutils.error(self,_("You have no movies in your database"), self.widgets['window']) return False current_poster_md5 = movie.poster_md5 if current_poster_md5: current_poster = gutils.get_image_fname(current_poster_md5, self.db) else: current_poster = None amazon.setLicense("04GDDMMXX8X9CJ1B22G2") locale = self.config.get('amazon_locale', 0, section='add') keyword = self.widgets['movie']['o_title'].get_text() if locale == '1': locale = 'uk' elif locale == '2': locale = 'de' keyword = self.widgets['movie']['title'].get_text() elif locale == '3': locale = 'ca' elif locale == '4': locale = 'fr' elif locale == '5': locale = 'jp' else: locale = None try: result = amazon.searchByTitle(keyword, type="Large", product_line="DVD", locale=locale) if hasattr(result, 'TotalPages'): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByTitle(keyword, type='Large', product_line='DVD', locale=locale, page=page) result.Item.extend(tmp.Item) page = page + 1 if not hasattr(result, 'Item') or not len(result.Item): # fallback if nothing is found by title result = amazon.searchByKeyword(keyword, type="Large", product_line="DVD", locale=locale) if hasattr(result, 'TotalPages'): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByKeyword(keyword, type='Large', product_line='DVD', locale=locale, page=page) result.Item.extend(tmp.Item) page = page + 1 log.info("... %s posters found" % result.TotalResults) except: gutils.warning(_("No posters found for this movie.")) return from widgets import connect_poster_signals, reconnect_add_signals connect_poster_signals(self, get_poster_select_dc, result, current_poster) if not hasattr(result, 'Item') or not len(result.Item): gutils.warning(_("No posters found for this movie.")) reconnect_add_signals(self) return if len(result.Item) == 1: o_title = self.widgets['movie']['o_title'].get_text().decode('utf-8') if o_title == result.Item[0].ItemAttributes.Title or keyword == result.Item[0].ItemAttributes.Title: get_poster(self, 0, result) return self.treemodel_results.clear() self.widgets['add']['b_get_from_web'].set_sensitive(False) # disable movie plugins (result window is shared) for f in range(len(result.Item)): if hasattr(result.Item[f], "LargeImage") and len(result.Item[f].LargeImage.URL): title = result.Item[f].ItemAttributes.Title if hasattr(result.Item[f].ItemAttributes, 'ProductGroup'): title = title + u' - ' + result.Item[f].ItemAttributes.ProductGroup elif hasattr(result.Item[f].ItemAttributes, 'Binding'): title = title + u' - ' + result.Item[f].ItemAttributes.Binding if hasattr(result.Item[f].ItemAttributes, 'ReleaseDate'): title = title + u' - ' + result.Item[f].ItemAttributes.ReleaseDate[:4] elif hasattr(result.Item[f].ItemAttributes, 'TheatricalReleaseDate'): result.Item[f].ItemAttributes.TheatricalReleaseDate[:4] if hasattr(result.Item[f].ItemAttributes, 'Studio'): title = title + u' - ' + result.Item[f].ItemAttributes.Studio myiter = self.treemodel_results.insert_before(None, None) self.treemodel_results.set_value(myiter, 0, str(f)) self.treemodel_results.set_value(myiter, 1, title) self.widgets['results']['window'].show() self.widgets['results']['window'].set_keep_above(True)
def toolbar_icon_clicked(self, widget, movie): log.info('fetching poster from Amazon...') self.movie = movie locale = self.get_config_value('locale', 'US').lower() accesskey = self.get_config_value('accesskey') secretkey = self.get_config_value('secretkey') if not accesskey or not secretkey: gutils.error(_('Please configure your Amazon Access Key ID and Secret Key correctly in the preferences dialog.')) return False if movie is None: gutils.error(_('You have no movies in your database'), self.widgets['window']) return False keyword = movie.o_title if locale == 'de': keyword = movie.title try: amazon.setLicense(accesskey, secretkey) result = amazon.searchByTitle(keyword, type='Large', product_line='DVD', locale=locale) if hasattr(result, 'TotalPages'): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByTitle(keyword, type='Large', product_line='DVD', locale=locale, page=page) result.Item.extend(tmp.Item) page = page + 1 if not hasattr(result, 'Item') or not len(result.Item): # fallback if nothing is found by title result = amazon.searchByKeyword(keyword, type='Large', product_line='DVD', locale=locale) if hasattr(result, 'TotalPages'): # get next result pages pages = int(result.TotalPages) page = 2 while page <= pages and page < 11: tmp = amazon.searchByKeyword(keyword, type='Large', product_line='DVD', locale=locale, page=page) result.Item.extend(tmp.Item) page = page + 1 self._result = result log.info("... %s posters found" % result.TotalResults) except: log.exception('') gutils.warning(_('No posters found for this movie.')) return if not hasattr(result, 'Item') or not len(result.Item): gutils.warning(_('No posters found for this movie.')) return if len(result.Item) == 1: o_title = self.widgets['movie']['o_title'].get_text().decode('utf-8') if o_title == result.Item[0].ItemAttributes.Title or keyword == result.Item[0].ItemAttributes.Title: self.get_poster(self.app, result.Item[0]) return # populate results window items = {} for i, item in enumerate(result.Item): if hasattr(item, 'LargeImage') and len(item.LargeImage.URL): title = item.ItemAttributes.Title if hasattr(item.ItemAttributes, 'ProductGroup'): title = title + u' - ' + item.ItemAttributes.ProductGroup elif hasattr(item.ItemAttributes, 'Binding'): title = title + u' - ' + item.ItemAttributes.Binding if hasattr(item.ItemAttributes, 'ReleaseDate'): title = title + u' - ' + item.ItemAttributes.ReleaseDate[:4] elif hasattr(item.ItemAttributes, 'TheatricalReleaseDate'): item.ItemAttributes.TheatricalReleaseDate[:4] if hasattr(item.ItemAttributes, 'Studio'): title = title + u' - ' + item.ItemAttributes.Studio items[i] = title populate_results_window(self.app.treemodel_results, items) self.widgets['add']['b_get_from_web'].set_sensitive(False) # disable movie plugins (result window is shared) self.app._resultswin_process = self.on_result_selected # use this signal (will be reverted when window is closed) self.widgets['results']['window'].show() self.widgets['results']['window'].set_keep_above(True)
preq.numberOfRecordsRequested presp.presentStatus = zdefs.PresentStatus.get_num_from_name('success') presp.records = ('responseRecords', self.format_records(preq.resultSetStartPoint, preq.numberOfRecordsRequested, res_set, preq.preferredRecordSyntax)) self.send_PDU('presentResponse', presp) def process_close(self, creq): close = zdefs.Close() close.closeReason = zdefs.CloseReason.get_num_from_name( 'responseToPeer') self.send_PDU('close', close) self.transport.loseConnection() if __name__ == '__main__': if 0: from PyZ3950 import z3950 print( rpn_q_to_amazon( ('type_1', z3950.mk_simple_query('Among the gently mad')))) print(rpn_q_to_amazon(('type_1', z3950.mk_compound_query()))) else: amazon.setLicense(amazon.getLicense()) factory = protocol.Factory() factory.protocol = Z3950Server reactor.listenTCP(2100, factory) reactor.run()
def __init__(self, config): QThread.__init__(self); self._queue = Queue(-1); amazon.setLicense(config.getAmazonKeyFile()); self._config = config; self._stopped = False;
def __init__(self, config): QThread.__init__(self) self._queue = Queue(15) amazon.setLicense(config.getAmazonKeyFile()) self._stopped = False
__parcel__ = "osaf.examples.amazon" import amazon import application from osaf.pim import ContentItem, ItemCollection import wx from application import schema amazon.setLicense('0X5N4AEK0PTPMZK1NNG2') def CreateCollection(repView, cpiaView): keywords = application.dialogs.Util.promptUser( wx.GetApp().mainFrame, "New Amazon Collection", "Enter your Amazon search keywords:", "Theodore Leung") newAmazonCollection = AmazonCollection(view=repView, keywords=keywords) return cpiaView.postEventByName('AddToSidebarWithoutCopying', {'items': [newAmazonCollection]}) def CreateWishListCollection(repView, cpiaView): emailAddr = application.dialogs.Util.promptUser( wx.GetApp().mainFrame, "New Amazon Wish List", "What is the Amazon email address of the wish list?", "") newAmazonCollection = AmazonCollection(view=repView, email=emailAddr) return cpiaView.postEventByName('AddToSidebarWithoutCopying', {'items': [newAmazonCollection]}) def NewCollectionFromKeywords(view, keywords, update=True): collection = AmazonCollection(keywords=keywords, view=view)