Skip to content

Commit

Permalink
new category, hd fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandmann79 committed Aug 2, 2015
1 parent 85f8979 commit 11cb40e
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 35 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</addon>
<addon id="plugin.video.amazon"
name="Amazon"
version="1.4.7"
version="1.4.8"
provider-name="Sandmann79 + BlueCop + Romans I XVI">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
Expand Down
2 changes: 1 addition & 1 deletion addon.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0a133649f6dd5d58c6ba424a92ec61bd
92a6ca245d4356e0f8ffc643514d7c55
2 changes: 1 addition & 1 deletion plugin.video.amazon/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.amazon"
name="Amazon"
version="1.4.7"
version="1.4.8"
provider-name="Sandmann79 + BlueCop + Romans I XVI">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions plugin.video.amazon/resources/language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<string id="30072">Verbose logging</string>

<string id="30100">Popular</string>
<string id="30101">Toggle watched state</string>
<string id="30102">Full Movie Refresh(DB)</string>
<string id="30103">Refresh TV &amp; Movie Database</string>
<string id="30104">Movies</string>
Expand Down Expand Up @@ -115,6 +116,7 @@
<string id="30146">Studios</string>
<string id="30147">MPAA Rating</string>
<string id="30148">Directors</string>
<string id="30149">Editor's Picks</string>

<string id="30154">Movie</string>
<string id="30155">Remove %s</string>
Expand Down
2 changes: 2 additions & 0 deletions plugin.video.amazon/resources/language/German/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<string id="30072">Ausführliches Logging</string>

<string id="30100">Beliebt</string>
<string id="30101">Gesehen Status ändern</string>
<string id="30102">Komplette Filmdatenbank erstellen</string>
<string id="30103">Film &amp; TV-Datenbank aktualisieren</string>
<string id="30104">Filme</string>
Expand Down Expand Up @@ -114,6 +115,7 @@
<string id="30146">Studios</string>
<string id="30147">Altersfreigabe</string>
<string id="30148">Regisseure</string>
<string id="30149">Empfehlungen</string>

<string id="30154">Film</string>
<string id="30155">%s entfernen</string>
Expand Down
2 changes: 1 addition & 1 deletion plugin.video.amazon/resources/lib/appfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def updateAll():
Notif(common.__plugin__, common.getString(30106), sound = False)
tv.addTVdb(False)
movies.addMoviesdb(False)
NewAsins = common.getNewest()
NewAsins = common.getCategories()
movies.setNewest(NewAsins)
movies.updateFanart()
tv.setNewest(NewAsins)
Expand Down
39 changes: 30 additions & 9 deletions plugin.video.amazon/resources/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ def addVideo(name,asin,poster=False,fanart=False,infoLabels=False,totalItems=0,c
cm = []
if int(addon.getSetting("playmethod")) == 0:
liz.setProperty('IsPlayable', 'true')
cm.insert(0, (getString(30109), 'XBMC.RunPlugin(%s&trailer=<0>&selbitrate=<1>)' % u) )
cm.insert(1, (getString(30113), 'XBMC.RunPlugin(%s&trailer=<0>&selbitrate=<org>)' % u) )
cm.insert(0, (getString(30109), 'RunPlugin(%s&trailer=<0>&selbitrate=<1>)' % u) )
cm.insert(1, (getString(30113), 'RunPlugin(%s&trailer=<0>&selbitrate=<org>)' % u) )
cm.insert(0, (getString(30101), 'Action(ToggleWatched)') )
if isHD:
liz.addStreamInfo('video', { 'width':1280 ,'height' : 720 })
else:
Expand Down Expand Up @@ -370,16 +371,30 @@ def checkCase(title):
title = title.title().replace('[Ov]', '[OV]').replace('Bc', 'BC')
return title

def getNewest():
def getCategories():
import urlparse
response = getURL(ATV_URL + '/cdp/catalog/GetCategoryList?firmware=fmw:15-app:1.1.23&deviceTypeID=A1MPSLFC7L5AFK&deviceID=%s&format=json&OfferGroups=B0043YVHMY&IncludeAll=T&version=2' % addon.getSetting("GenDeviceID"))
data = demjson.decode(response)
asins = {}
for type in data['message']['body']['categories'][0]['categories'][0]['categories']:
subPageType = None
if type.has_key('subPageType'): subPageType = type['subPageType']
if subPageType == 'PrimeMovieRecentlyAdded' or subPageType == 'PrimeTVRecentlyAdded':
asins.update({subPageType: urlparse.parse_qs(type['query'])['ASINList'][0].split(',')})
for maincat in data['message']['body']['categories']:
mainCatId = maincat.get('id')
if mainCatId == 'movies' or mainCatId == 'tv_shows':
asins.update({mainCatId: {}})
for type in maincat['categories'][0]['categories']:
subPageType = type.get('subPageType')
subCatId = type.get('id')
if subPageType == 'PrimeMovieRecentlyAdded' or subPageType == 'PrimeTVRecentlyAdded':
asins[mainCatId].update({subPageType: urlparse.parse_qs(type['query'])['ASINList'][0].split(',')})
elif 'prime_editors_picks' in subCatId:
for picks in type['categories']:
query = picks.get('query').upper()
title = picks.get('title')
if title and ('ASINLIST' in query):
querylist = urlparse.parse_qs(query)
alkey = None
for key in querylist.keys():
if 'ASINLIST' in key: alkey = key
asins[mainCatId].update({title: urlparse.parse_qs(query)[alkey][0]})
return asins

def SetView(content, view=False, updateListing=False):
Expand Down Expand Up @@ -491,7 +506,13 @@ def copyDB(ask=False):
cur_fileacc = int(os.path.getmtime(tvDBfile) + os.path.getmtime(MovieDBfile))
if org_fileacc > cur_fileacc:
copyDB(True)

if 1 == 0:
import movies
import tv
NewAsins = getCategories()
movies.setNewest(NewAsins)
tv.setNewest(NewAsins)
#tv.cleanDB()
urlargs = urllib.unquote_plus(sys.argv[2][1:].replace('&', ', ')).replace('<','"').replace('>','"')
Log('Args: %s' % urlargs)
exec "args = _Info(%s)" % urlargs
14 changes: 14 additions & 0 deletions plugin.video.amazon/resources/lib/listmovie.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
def LIST_MOVIE_ROOT():
common.addDir(common.getString(30100),'listmovie','LIST_MOVIES_SORTED','popularity')
common.addDir(common.getString(30110),'listmovie','LIST_MOVIES_SORTED','recent')
common.addDir(common.getString(30149),'listmovie','LIST_MOVIES_CATS')
common.addDir(common.getString(30143),'listmovie','LIST_MOVIES')
common.addDir(common.getString(30144),'listmovie','LIST_MOVIE_TYPES','genres')
common.addDir(common.getString(30145),'listmovie','LIST_MOVIE_TYPES','year')
Expand All @@ -24,6 +25,19 @@ def LIST_MOVIE_ROOT():
common.addDir(common.getString(30148),'listmovie','LIST_MOVIE_TYPES','director')
xbmcplugin.endOfDirectory(pluginhandle)

def LIST_MOVIES_CATS():
import movies as moviesDB
id = common.args.url
if id:
asins = moviesDB.lookupMoviedb(id, rvalue='asins', name='title', table='categories')
for asin in asins.split(','):
LIST_MOVIES('asin',asin,search=True)
common.SetView('movies', 'movieview')
else:
for title in moviesDB.lookupMoviedb('', name='asins', table='categories', single=False):
if title: common.addDir(title[0],'listmovie','LIST_MOVIES_CATS',title[0])
xbmcplugin.endOfDirectory(pluginhandle,updateListing=False)

def LIST_MOVIE_TYPES(type=False):
import movies as moviesDB
if not type:
Expand Down
24 changes: 24 additions & 0 deletions plugin.video.amazon/resources/lib/listtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
def LIST_TV_ROOT():
common.addDir(common.getString(30100),'listtv','LIST_TVSHOWS_SORTED','popularity')
common.addDir(common.getString(30110),'listtv','LIST_TVSEASON_SORTED','recent')
common.addDir(common.getString(30149),'listtv','LIST_TVSHOWS_CATS')
common.addDir(common.getString(30160),'listtv','LIST_TVSHOWS')
common.addDir(common.getString(30144),'listtv','LIST_TVSHOWS_TYPES','genres' )
common.addDir(common.getString(30158),'listtv','LIST_TVSHOWS_TYPES','actors')
Expand All @@ -24,6 +25,29 @@ def LIST_TV_ROOT():
common.addDir(common.getString(30162),'listtv','LIST_TVSHOWS_TYPES','mpaa' )
xbmcplugin.endOfDirectory(pluginhandle)

def LIST_TVSHOWS_CATS():
import tv as tvDB
id = common.args.url
if id:
asins = tvDB.lookupTVdb(id, rvalue='asins', name='title', tbl='categories')
epidb = tvDB.lookupTVdb('', name='asin', rvalue='asin, seasonasin', tbl='episodes', single=False)
if not asins: return
for asin in asins.split(','):
seasonasin = None
for epidata in epidb:
if asin in str(epidata):
seasonasin = epidata[1]
break
if not seasonasin: seasonasin = asin
for seasondata in tvDB.loadTVSeasonsdb(seasonasin=seasonasin).fetchall():
ADD_SEASON_ITEM(seasondata, disptitle=True)
common.SetView('tvshows', 'seasonview')
del epidb
else:
for title in tvDB.lookupTVdb('', name='asins', tbl='categories', single=False):
if title: common.addDir(title[0],'listtv','LIST_TVSHOWS_CATS',title[0])
xbmcplugin.endOfDirectory(pluginhandle,updateListing=False)

def LIST_TVSHOWS_TYPES(type=False):
import tv as tvDB
if not type:
Expand Down
28 changes: 20 additions & 8 deletions plugin.video.amazon/resources/lib/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
def createMoviedb():
c = MovieDB.cursor()
c.execute('drop table if exists movies')
c.execute('drop table if exists categories')
c.execute('''create table movies
(asin UNIQUE,
HDasin UNIQUE,
Expand Down Expand Up @@ -62,10 +63,11 @@ def addMoviedb(moviedata):
MovieDB.commit()
return num

def lookupMoviedb(value, rvalue='distinct *', name='asin', single=True, exact=False):
def lookupMoviedb(value, rvalue='distinct *', name='asin', single=True, exact=False, table='movies'):
common.waitforDB('movie')
c = MovieDB.cursor()
sqlstring = 'select %s from movies where %s ' % (rvalue, name)
if not c.execute('SELECT count(*) FROM sqlite_master WHERE type="table" AND name=(?)', (table,)).fetchone()[0]: return ''
sqlstring = 'select %s from %s where %s ' % (rvalue, table, name)
retlen = len(rvalue.split(','))
if not exact:
value = '%' + value + '%'
Expand Down Expand Up @@ -206,15 +208,25 @@ def updateLibrary(asinlist=False):
for title in titles:
ASIN_ADD(title)

def setNewest(asins=False):
if not asins:
asins = common.getNewest()
def setNewest(compList=False):
if not compList:
compList = common.getCategories()
catList = compList['movies']
c = MovieDB.cursor()
c.execute('drop table if exists categories')
c.execute('''create table categories(
title TEXT,
asins TEXT);''')
c.execute('update movies set recent=null')
count = 1
for asin in asins['PrimeMovieRecentlyAdded']:
updateMoviedb(asin, 'recent', count)
count += 1
for id in catList:
if id == 'PrimeMovieRecentlyAdded':
for asin in catList[id]:
updateMoviedb(asin, 'recent', count)
count += 1
else:
c.execute('insert or ignore into categories values (?,?)', [id, catList[id]])
MovieDB.commit()

def updateFanart():
if tmdb_art == '0': return
Expand Down
5 changes: 3 additions & 2 deletions plugin.video.amazon/resources/lib/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ def GETFLASHVARS(pageurl):
Dialog.notification(common.getString(30200), common.getString(30210), xbmcgui.NOTIFICATION_ERROR)
return False

values['deviceTypeID'] = 'A324MFXUEZFF7B' #Sony GoogleTV unenc Flash
#values['deviceTypeID'] = 'A324MFXUEZFF7B' #Sony GoogleTV unenc Flash
#values['deviceTypeID'] = 'A13Q6A55DBZB7M' #enc Flash
#values['deviceTypeID'] = 'A35LWR0L7KC0TJ' #Logitech GoogleTV unenc Flash
values['deviceTypeID'] = 'A35LWR0L7KC0TJ' #Logitech GoogleTV unenc Flash
#values['deviceTypeID'] = 'A63V4FRV3YUP9' #enc Silverlight
values['userAgent'] = "GoogleTV"
values['deviceID'] = common.hmac.new(common.UserAgent, common.gen_id(), hashlib.sha224).hexdigest()
Expand Down Expand Up @@ -326,6 +326,7 @@ def PLAY(rtmpurls,values,Trailer,title):
item.setArt({'tvshow.poster': infoLabels['Poster']})
else:
item.setArt({'poster': infoLabels['Thumb']})

item.setInfo(type="Video", infoLabels=infoLabels)

if Trailer or selbitrate != '0':
Expand Down
49 changes: 37 additions & 12 deletions plugin.video.amazon/resources/lib/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def createTVdb():
c.execute('drop table if exists shows')
c.execute('drop table if exists seasons')
c.execute('drop table if exists episodes')
c.execute('drop table if exists categories')
c.execute('''CREATE TABLE shows(
asin TEXT UNIQUE,
seriestitle TEXT,
Expand Down Expand Up @@ -247,6 +248,7 @@ def addDB(table, data):
def lookupTVdb(value, rvalue='distinct *', tbl='episodes', name='asin', single=True, exact=False):
common.waitforDB('tv')
c = tvDB.cursor()
if not c.execute('SELECT count(*) FROM sqlite_master WHERE type="table" AND name=(?)', (tbl,)).fetchone()[0]: return ''
sqlstring = 'select %s from %s where %s ' % (rvalue, tbl, name)
retlen = len(rvalue.split(','))
if not exact:
Expand Down Expand Up @@ -287,7 +289,7 @@ def delfromTVdb():
if item: delasins += (item)
UpdateDialog(0, 0, 0, *deleteremoved(delasins))

def deleteremoved(asins):
def deleteremoved(asins, refresh=True):
c = tvDB.cursor()
delShows = 0
delSeasons = 0
Expand All @@ -304,15 +306,28 @@ def deleteremoved(asins):
delShows += c.execute('delete from shows where seriestitle = (?)', (title,)).rowcount
tvDB.commit()
c.close()
xbmc.executebuiltin('Container.Refresh')
if refresh: xbmc.executebuiltin('Container.Refresh')
return delShows, delSeasons, delEpisodes

def cleanDB():
c = tvDB.cursor()
episodeasins = getTVdbAsins('episodes', 2, value='seasonasin')
removeAsins = []
for asins, season in lookupTVdb('', rvalue='asin, season', tbl='seasons', name='asin', single=False):
foundSeason = False
for asin in asins.split(','):
if asin in episodeasins: foundSeason = True
if not foundSeason: removeAsins.append(asins)
if len(removeAsins): UpdateDialog(0, 0, 0, *deleteremoved(removeAsins, False))
del episodeasins#,seasonasins

def getTVdbAsins(table, isPrime=1, list=False):
def getTVdbAsins(table, isPrime=1, list=False, value='asin'):
c = tvDB.cursor()
content = ''
if list:
content = []
sqlstring = 'select asin from %s where isPrime = (%s)' % (table, isPrime)
sqlstring = 'select %s from %s' % (value,table)
if isPrime < 2: sqlstring += ' where isPrime = (%s)' % isPrime
for item in c.execute(sqlstring).fetchall():
if list:
content.append([','.join(item), 0])
Expand Down Expand Up @@ -344,6 +359,7 @@ def addTVdb(full_update = True, libasins = False):
ALL_SERIES_ASINS = ''
ALL_SEASONS_ASINS = []
else:
cleanDB()
ALL_SEASONS_ASINS = getTVdbAsins('seasons', list=True)
ALL_SERIES_ASINS = getTVdbAsins('shows')

Expand Down Expand Up @@ -653,17 +669,26 @@ def getIMDbID(asins,title):
common.Log(id + asins.split(',')[0])
return id

def setNewest(asins=False):
if not asins:
asins = common.getNewest()
def setNewest(compList=False):
if not compList:
compList = common.getCategories()
catList = compList['tv_shows']
c = tvDB.cursor()
c.execute('drop table if exists categories')
c.execute('''create table categories(
title TEXT,
asins TEXT);''')
c.execute('update seasons set recent=null')
count = 1
for asin in asins['PrimeTVRecentlyAdded']:
seasonasin = lookupTVdb(asin, rvalue='seasonasin')
if not seasonasin: seasonasin = asin
c.execute("update seasons set recent=? where asin like (?)", (count, '%'+seasonasin+'%'))
count += 1
for id in catList:
if id == 'PrimeTVRecentlyAdded':
for asin in catList[id]:
seasonasin = lookupTVdb(asin, rvalue='seasonasin')
if not seasonasin: seasonasin = asin
c.execute("update seasons set recent=? where asin like (?)", (count, '%'+seasonasin+'%'))
count += 1
else:
c.execute('insert or ignore into categories values (?,?)', [id, catList[id]])
tvDB.commit()

if not os.path.exists(common.tvDBfile):
Expand Down

0 comments on commit 11cb40e

Please sign in to comment.