[RELEASE] Amazon Prime Instant Video plug-in addon

  Thread Rating:
  • 14 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
BlueCop Offline
Skilled Python Coder
Posts: 1,430
Joined: May 2004
Reputation: 71
Post: #46
some shows don't have genre listed on their page. They aren't listed under genres right now.

I want incremental updates. it would be much faster. I am a novice to database queries which is probably slowing me down.

I had the idea of displaying the cache to the user and then silently updating the cache in the background for new items.
find quote
ndeshmukh Offline
Member
Posts: 87
Joined: Aug 2010
Reputation: 1
Post: #47
I can understand, last week has been my crash course in python, together with sqlite and sql querries for the first time, but making the db was a process where i would inveritably have xbmc crashing on me, so i made sure that the update to db was incremental. Check if in db, if not then query tvdb, that was my logic, and also cache a state whre you querry tvdb and if not found save that state, so that you don't keep going over and over the same shows.

I was thinking of adding a date column of when the tvdb was queried for that show, and next time if db is asked for it and state says not found in tvdb, but was checked like a month back, then it can re-query tvdb for that item.
find quote
BlueCop Offline
Skilled Python Coder
Posts: 1,430
Joined: May 2004
Reputation: 71
Post: #48
I committed small update to change to use mechanize for login. It should work much better. It also will inform the user if the email or password is incorrect.

thanks to mighty_bombero for the code.
find quote
cmo1982 Offline
Junior Member
Posts: 10
Joined: Aug 2011
Reputation: 0
Post: #49
Sorry about that - I'm clearly a noob here. I'll repost.
(This post was last modified: 2011-09-05 13:53 by cmo1982.)
find quote
BlueCop Offline
Skilled Python Coder
Posts: 1,430
Joined: May 2004
Reputation: 71
Post: #50
please don't post logs on the forum. please delete it and post it to a paste service. it is much harder to read a jumbled mess.

what platform are you on? seems to be a mechanize module problem.
find quote
cmo1982 Offline
Junior Member
Posts: 10
Joined: Aug 2011
Reputation: 0
Post: #51
I'm running under Windows 7, 32-bit:

Here is a link to my log:
http://paste.bradleygill.com/index.php?paste_id=323903

Thanks again, and sorry!
find quote
BlueCop Offline
Skilled Python Coder
Posts: 1,430
Joined: May 2004
Reputation: 71
Post: #52
cmo1982: it seems to be a bug in handling redirects in python 2.4. The server sends a HTTP Error 302 Moved temporarily to redirect to the sign-in page. the redirected page has a space in it and it should be encoded as '%20' but isn't and throws an error because python wants it encoded correctly.

I can add an option to use the old login code for people using that version of python. It isn't as reliable. It also seems slower to me. I haven't actually timed it though.

which xbmc build are you using?
find quote
devicenull Offline
Junior Member
Posts: 17
Joined: Sep 2011
Reputation: 0
Post: #53
I'm having some issues playing back anything at all. I try to select a category ('Television', 'Movies', etc).. and nothing happens. No loading message, no error, just nothing.

xbmc.log: http://pastebin.com/iHZHMf2N
Python version: Python 2.6.7 (r267:88850, Jul 10 2011, 08:11:54)
XBMC Version: 10.1-0.7
Plugin Version: 0.2.4

Any suggestions?
find quote
devicenull Offline
Junior Member
Posts: 17
Joined: Sep 2011
Reputation: 0
Post: #54
Btw, I took a look at your database structure, I'd recommend something like this instead:

Quote:create table shows (
seriestitle text
,season integer
,episode integer
,HD boolean

,url text
,poster text
,plot text
,creator text
,runtime text
,year integer
,network text
,actors text
,genres text
,stars float
,votes string

,primary key (seriestitle, season, episode, HD)
);

create table movies (
movietitle text
,year integer

,url text
,poster text
,plot text
,director text
,runtime text
,premiered text
,studio text
,mpaa text
,actors text
,genres text
,stars float
,votes string

,primary key (movietitle, year)
);

This would let you do something like:
Quote:insert on conflict ignore into shows..
and the database would take care of getting rid of duplicates for you. It would also make some of the loadMoviedb functions faster, as SQLite would be able to make use of the primary key instead of having to do a full table scan. You would also be able to get rid of the 'select distinct' you are using, as you wouldn't have any duplicates in the first place.
find quote
BlueCop Offline
Skilled Python Coder
Posts: 1,430
Joined: May 2004
Reputation: 71
Post: #55
devicenull: I am actually redoing the database structure with 2 tables. I did it for movies. it has movies and moviedata. I assigned the asin(amazon standard id number) as the primary key in each. movies is just title,url,poster. everything scraped from the initial page. It is just the prime movies.

I can use moviedata so cache metadata for My Library items as well so it doesn't have to look them up each time. If it encounter a new item it scrapes and caches it. The asin is unique among all videos so I thought it would work well for the primary key. I will look into preventing duplicates like you suggested.

It also has tvdb and tmdb options.

anyway I hope the database code will look better soon. I would love for you to suggest any improvements on the new code when I post it. anyway I am off to lunch.
find quote
ztas Offline
Member
Posts: 77
Joined: Feb 2011
Reputation: 0
Post: #56
Thanks for the excellent addon.
I'm able to play My Videos on AppleTV2.

Now i'm ready to rent a movie and try playing it.
find quote
devicenull Offline
Junior Member
Posts: 17
Joined: Sep 2011
Reputation: 0
Post: #57
devicenull Wrote:I'm having some issues playing back anything at all. I try to select a category ('Television', 'Movies', etc).. and nothing happens. No loading message, no error, just nothing.

xbmc.log: http://pastebin.com/iHZHMf2N
Python version: Python 2.6.7 (r267:88850, Jul 10 2011, 08:11:54)
XBMC Version: 10.1-0.7
Plugin Version: 0.2.4

Any suggestions?

Did some further digging. pluginhandle is set to '-1' when addDir is getting called, this is leading to the 'ERROR: AddItem - called with an invalid handle.' error. Any ideas why this would happen?

Edit: Found it! http://trac.xbmc.org/ticket/11584 . The quick workaround is to remove the totalItems=totalItems from this line in addDir (currently line 58 in default.py):
ok=xbmcplugin.addDirectoryItem(handle=pluginhandle,url=u,listitem=liz,isFolder=T​rue,totalItems=totalItems)

I'm not sure if this will cause any issues, but it's letting me browse directories successfully. Based on my understanding of the bug, this would only manifest itself on x64 builds of xbmc.
(This post was last modified: 2011-09-06 04:54 by devicenull.)
find quote
BlueCop Offline
Skilled Python Coder
Posts: 1,430
Joined: May 2004
Reputation: 71
Post: #58
I committed an update so it can now cache the metadata on the fly for new items in your library. The queue feature will also make use of this.

it has a lot of under the hood changes for the next update. It will include tvdb and tmdb module support for better posters and fanart. It can also supplement the database a bit too.

It will be pretty easy to update too because I can process the releases in the past 30 days page and have it update the database with the newest items. It will also be possible to do a full movie or tv show rescan without metadata update. This is relatively quick because it is much fewer web requests. It is slow doing a full database with metadata rebuild though.

devicenull: I am a sql novice so appreciate any sql suggestions. if you want to check out the current code.

Some duplicates are in the amazon database itself. They don't duplicate asin but do duplicate content exactly. In fact a few deep space nine season 1 episodes a peppered through out the show list. Deep space nine also has a couple season 5 listings on amazon. I am just going to make removing items from the database as a context items in xbmc so one can prune items they dislike.
find quote
devicenull Offline
Junior Member
Posts: 17
Joined: Sep 2011
Reputation: 0
Post: #59
I'm not certain why you switched over to having two tables. In general, I'd only split the tables if there was the possibility of having a 1-to-N relationship between them, or a few other special circumstances.

It looks like you are populating the tables at different times. I'd suggest having one table, and either a hasData bool flag in it, or detecting the metadata based on the presence of data for one of the fields.

BTW, this query appears to be incorrect:
Quote:metadata = c.execute('select asin,plot,director,runtime,year,premiered,studio,mpaa,actors,genres,stars,votes,​TMDBbanner,TMDBposter,TMDBfanart string from moviedata where asin = (?)', (asin,))
note the extra 'string' in there after TMDBfanart.

Also, I'd suggest sharing one sqlite connection handle through the entire plugin, rather then constantly opening a new one for each function. Probably not a big deal, but should be a minor performance boost.
find quote
BlueCop Offline
Skilled Python Coder
Posts: 1,430
Joined: May 2004
Reputation: 71
Post: #60
devicenull: the tables serve different purposes. Not all metadata is for the prime items. the movies table is only prime movies. The moviedata table is used to cache all movie metadata for any asin encountered. This would include My Library and the new feature My Queue when I commit it. the data in the movies table are always updated from a list source. the data in moviedata are always updated from page source. the list source is scraped for some things My Library.

I am also adding scraping items for some prime items as well. The past 30 days of new movies will always be a new scraped list. When the list is loaded any new items metadata for it is saved. It will also add those items to your prime library if missing.

what is a 1-to-N relationship?
why does it matter when I populate them?

I will make it one connection and use different cursors. I fixed that query.
find quote
Post Reply