def run_search(self):
     self.result = []
     try:
         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:
             log.exception('Error retrieving results from amazon.')
         # 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.exception('Error retrieving results from amazon.')
             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.exception('Error retrieving results from amazon.')
 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)
예제 #3
0
 def run_search(self):
     self.result = []
     try:
         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:
             log.exception('Error retrieving results from amazon.')
         # 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.exception('Error retrieving results from amazon.')
             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.exception('Error retrieving results from amazon.')
예제 #4
0
					#print "found all bits", items, k
					use_a = k
					break
		if use_a != None:
			if newest == None or newest < albums[use_a]['when']:
				newest = albums[use_a]['when']
		else:
			print "Can't find '%s'"%got_a, albums.keys()

	for a in albums.keys():
		if albums[a]['when'] > newest and not albums[a]['ep']:
			#print "don't have",a, albums[a]['asin'], artist
			cur.execute("select url, image, amazon_new from amazon where artist=? and album=?",(artist, a))
			d = cur.fetchall()
			if d == []:
				results = amazon.searchByTitle(artist, a)
				cur.execute("insert into amazon values(?, ?, ?, ?, ?)",(artist, a, unicode(results["url"]), unicode(results["image"]), results["amazon_new"]))
				con.commit()
			else:
				d = d[0]
				def realNone(x):
					if x == "None":
						return None
					else:
						return x
				d = [realNone(x) for x in d]
				results = {"title":a, "url":d[0], "image":d[1], "amazon_new":d[2]}
			print "missing",results, albums[a]['when'], artist
			when = albums[a]['when']
			if when not in missing:
				missing[when] = []
예제 #5
0
    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)
예제 #6
0
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)
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
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)