The branch, frodo has been updated
via c0ea651702a09769c92da0e5914beff021824b17 (commit)
from b1aaf47440f149b1f554534f8f0d14d73dcaf375 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=c0ea651702a09769c92da0e5914beff021824b17
commit c0ea651702a09769c92da0e5914beff021824b17
Author: beenje <[email protected]>
Date: Sun Jun 2 06:44:59 2013 +0200
[plugin.video.trailer.addict] updated to version 2.0.9
diff --git a/plugin.video.trailer.addict/addon.xml
b/plugin.video.trailer.addict/addon.xml
index 821b3d3..053450d 100644
--- a/plugin.video.trailer.addict/addon.xml
+++ b/plugin.video.trailer.addict/addon.xml
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.trailer.addict"
name="Trailer Addict"
- version="2.0.8"
+ version="2.0.9"
provider-name="stacked">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
+ <import addon="script.module.parsedom" version="1.3.0"/>
+ <import addon="script.module.simple.downloader" version="0.9.3"/>
<import addon="script.module.buggalo" version="1.1.2"/>
+ <import addon="script.module.simplejson" version="2.0.10"/>
</requires>
<extension point="xbmc.python.pluginsource"
library="default.py">
@@ -16,5 +19,9 @@
<description lang="en">Watch movie trailers for upcoming, new and classic
films.</description>
<platform>all</platform>
<language>en</language>
+ <website>https://code.google.com/p/plugin</website>
+ <source>https://github.com/stacked/plugin.video.trailer.addict</source>
+ <forum>http://forum.xbmc.org/showthread.php?tid=53821</forum>
+ <email>[email protected]</email>
</extension>
</addon>
diff --git a/plugin.video.trailer.addict/addonfunc.py
b/plugin.video.trailer.addict/addonfunc.py
index efb539a..bed7e69 100644
--- a/plugin.video.trailer.addict/addonfunc.py
+++ b/plugin.video.trailer.addict/addonfunc.py
@@ -2,22 +2,36 @@
Addon Functions
__author__ = 'stacked <[email protected]>'
__url__ = 'http://code.google.com/p/plugin/'
-__date__ = '01-12-2013'
-__version__ = '0.0.6'
+__date__ = '06-01-2013'
+__version__ = '0.0.10'
'''
import xbmc, xbmcgui, xbmcaddon, xbmcplugin, urllib, urllib2, sys, time,
datetime, buggalo
+from urlparse import urlparse
+from os.path import splitext, basename
settings = sys.modules["__main__"].settings
plugin = sys.modules["__main__"].plugin
-useragent = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101
Firefox/17.0'
+useragent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101
Firefox/21.0'
+import SimpleDownloader as downloader
+downloader = downloader.SimpleDownloader()
-def addListItem(label, image, url, isFolder, infoLabels = False, fanart =
False, duration = False):
+def addListItem(label, image, url, isFolder, totalItems, infoLabels = False,
fanart = False, duration = False, cm = False):
listitem = xbmcgui.ListItem(label = label, iconImage = image,
thumbnailImage = image)
+ if url['mode']:
+ u = sys.argv[0] + '?' + urllib.urlencode(url)
+ else:
+ u = url['url']
if not isFolder:
if settings.getSetting('download') == '' or
settings.getSetting('download') == 'false':
- listitem.setProperty('IsPlayable', 'true')
+ if label != '* ' + settings.getLocalizedString( 30030 )
+ ' *':
+ listitem.setProperty('IsPlayable', 'true')
+ if settings.getSetting('playall') == 'true':
+ playlist =
xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
+ playlist.add(url = u, listitem =
listitem)
if fanart:
listitem.setProperty('fanart_image', fanart)
+ if cm:
+ listitem.addContextMenuItems( cm )
if infoLabels:
listitem.setInfo(type = 'video', infoLabels = infoLabels)
if duration:
@@ -25,11 +39,7 @@ def addListItem(label, image, url, isFolder, infoLabels =
False, fanart = False,
listitem.addStreamInfo('video', { 'duration':
int(duration) })
else:
listitem.setInfo(type = 'video', infoLabels = {
'duration': str(datetime.timedelta(milliseconds=int(duration)*1000)) } )
- if url['mode']:
- u = sys.argv[0] + '?' + urllib.urlencode(url)
- else:
- u = url['url']
- ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u,
listitem = listitem, isFolder = isFolder)
+ ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u,
listitem = listitem, isFolder = isFolder, totalItems = int(totalItems))
return ok
def playListItem(label, image, path, infoLabels, PlayPath = False):
@@ -48,7 +58,7 @@ def getUrl(url, gzip = False):
data = getPage(url, gzip)
if data['content'] != None and data['error'] == None:
return data['content']
- if data['error'].find('404:') != -1:
+ if data['error'].find('404:') != -1 or
data['error'].find('400:') != -1:
break
except Exception, e:
data['error'] = str(e)
@@ -98,6 +108,34 @@ def setViewMode(id, type = False):
xbmcplugin.setContent(int( sys.argv[1] ), type)
if settings.getSetting('view') == 'true':
xbmc.executebuiltin('Container.SetViewMode(' + id + ')')
+
+def start_download(name, path):
+ try:
+ ext = splitext(basename(urlparse(path).path))[1]
+ except:
+ ext = '.mp4'
+ dialog = xbmcgui.Dialog()
+ #dir = dialog.browse(0, settings.getLocalizedString( 30059 ), 'files',
'', False, False, settings.getSetting('downloadPath'))
+ if settings.getSetting('downloadPrompt') == 'true':
+ dir = dialog.browse(0, settings.getLocalizedString( 30059 ),
'files')
+ else:
+ while not settings.getSetting('downloadPath'):
+ ok = dialog.ok(plugin, settings.getLocalizedString(
30058 ))
+ settings.openSettings()
+ if settings.getSetting('downloadPrompt') == 'true':
+ dir = dialog.browse(0, 'XBMC', 'files')
+ settings.setSetting('downloadPath', dir)
+ dir = settings.getSetting('downloadPath')
+ if len(dir) == 0:
+ return
+ params = { "url": path, "download_path": dir, "Title": name }
+ downloader.download(clean_file(name) + ext, params)
+
+def clean_file(name):
+ remove=[('\"',''),('\\',''),('/',''),(':',' -
'),('|',''),('>',''),('<',''),('?',''),('*','')]
+ for old, new in remove:
+ name=name.replace(old,new)
+ return name
#From http://wiki.xbmc.org/index.php?title=Add-on:Parsedom_for_xbmc_plugins
def getParameters(parameterString):
diff --git a/plugin.video.trailer.addict/changelog.txt
b/plugin.video.trailer.addict/changelog.txt
index 4967161..3901530 100644
--- a/plugin.video.trailer.addict/changelog.txt
+++ b/plugin.video.trailer.addict/changelog.txt
@@ -1,3 +1,10 @@
+[B]Version 2.0.9[/B]
+
+- Added Download context menu
+- Added CouchPotato context menu
+- Added 'Library' folder to search for trailers from scanned movies
+- Fixed error when loading movies without trailers
+
[B]Version 2.0.8[/B]
- Version bump for frodo
diff --git a/plugin.video.trailer.addict/default.py
b/plugin.video.trailer.addict/default.py
index 81cbad6..5f0a57c 100644
--- a/plugin.video.trailer.addict/default.py
+++ b/plugin.video.trailer.addict/default.py
@@ -1,15 +1,21 @@
import xbmc, xbmcgui, xbmcplugin, xbmcaddon, urllib, re, string, sys, os,
buggalo
+import simplejson as json
plugin = 'Trailer Addict'
__author__ = 'stacked <[email protected]>'
__url__ = 'http://code.google.com/p/plugin/'
-__date__ = '01-27-2013'
-__version__ = '2.0.8'
+__date__ = '06-01-2013'
+__version__ = '2.0.9'
settings = xbmcaddon.Addon( id = 'plugin.video.trailer.addict' )
buggalo.SUBMIT_URL = 'http://www.xbmc.byethost17.com/submit.php'
+dbg = False
+dbglevel = 3
+import CommonFunctions
+common = CommonFunctions
+common.plugin = plugin + ' ' + __version__
-from addonfunc import addListItem, playListItem, getUrl, getPage, setViewMode,
getParameters, retry
+from addonfunc import addListItem, playListItem, getUrl, getPage, setViewMode,
getParameters, retry, start_download
next_thumb = os.path.join( settings.getAddonInfo( 'path' ), 'resources',
'media', 'next.png' )
search_thumb = os.path.join( settings.getAddonInfo( 'path' ), 'resources',
'media', 'search_icon.png' )
@@ -18,6 +24,8 @@ film_reel_thumb = os.path.join( settings.getAddonInfo( 'path'
), 'resources', 'm
oscar_thumb = os.path.join( settings.getAddonInfo( 'path' ), 'resources',
'media', 'oscar.png' )
popcorn_thumb = os.path.join( settings.getAddonInfo( 'path' ), 'resources',
'media', 'popcorn.png' )
poster_thumb = os.path.join( settings.getAddonInfo( 'path' ), 'resources',
'media', 'poster.png' )
+library_thumb = os.path.join( settings.getAddonInfo( 'path' ), 'resources',
'media', 'library.png' )
+icon_thumb = os.path.join( settings.getAddonInfo( 'path' ), 'icon.png' )
def clean( name ):
list = [ ( '&', '&' ), ( '"', '"' ), ( '<em>', '' ), (
'</em>', '' ), ( ''', '\'' ) ]
@@ -26,9 +34,10 @@ def clean( name ):
return name
@retry((IndexError, TypeError))
-def find_trailers( url, name ):
+def find_trailers( url, name, page, library ):
save_name = name
- data = getUrl( url )
+ save_page = page
+ data = getUrl( url ).decode('ascii', 'ignore')
link_thumb = re.compile( '<a href="(.+?)"><img src="(.+?)" name="thumb'
).findall( data )
thumbs = re.compile( 'img src="/psize\.php\?dir=(.+?)" style'
).findall( data )
if len( thumbs ) == 0:
@@ -38,52 +47,127 @@ def find_trailers( url, name ):
title = re.compile( '<div class="abstract"><h2><a
href="(.+?)">(.+?)</a></h2><br />', re.DOTALL ).findall( data )
trailers = re.compile( '<dl class="dropdown">(.+?)</dl>', re.DOTALL
).findall( data )
if len(title) == 0 and len(trailers) == 0:
- dialog = xbmcgui.Dialog()
- ok = dialog.ok(plugin, settings.getLocalizedString( 30012 ))
- ok = dialog.ok(plugin, settings.getLocalizedString( 30051 ))
- buggalo.addExtraData('url', url)
- buggalo.addExtraData('name', name)
- raise Exception('find_trailers Error 1')
+ list = common.parseDOM(data, "div", attrs = { "class": "info" })
+ header = common.parseDOM(data, "div", attrs = { "class":
"trailerheader" })
+ nexturl = common.parseDOM(header, "a", attrs = { "title": "Next
Page" }, ret = "href")
+ totalItems = len(list)
+ if totalItems == 0:
+ dialog = xbmcgui.Dialog()
+ ok = dialog.ok(plugin, settings.getLocalizedString(
30012 ))
+ ok = dialog.ok(plugin, settings.getLocalizedString(
30051 ))
+ buggalo.addExtraData('url', url)
+ buggalo.addExtraData('name', name)
+ raise Exception('find_trailers Error A')
+ return
+ for video in list:
+ h2 = common.parseDOM(video, "h2")
+ title = common.parseDOM(h2, "a")[0]
+ url = 'http://www.traileraddict.com' +
common.parseDOM(h2, "a", ret = "href")[0]
+ thumb = 'http://www.traileraddict.com' +
common.parseDOM(video, "img", attrs = { "class": "dimmer" }, ret =
"src")[0].replace('-t.jpg','.jpg')
+ #infoLabels = { "Title": title, "Plot": save_name + '
(' + clean( title ) + ')' }
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({ 'mode':
'5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url, 'download':
'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ cm.append( (settings.getLocalizedString(30014),
"XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)"
% save_name) )
+ u = { 'mode': '5', 'name': save_name + ' (' + clean(
title ) + ')', 'url': url }
+ addListItem(label = clean( title ), image = thumb, url
= u, isFolder = False, totalItems = totalItems, infoLabels = False, cm = cm)
+ if len(nexturl) > 0:
+ url = 'http://www.traileraddict.com' + nexturl[0]
+ u = { 'mode': '4', 'name': save_name, 'url': url,
'page': str( int( save_page ) + 1 ) }
+ addListItem(label = '[Next Page (' + str( int(
save_page ) + 2 ) + ')]', image = next_thumb, url = u, isFolder = True,
totalItems = 0, infoLabels = False)
+ xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod
= xbmcplugin.SORT_METHOD_NONE )
+ setViewMode("502", "movies")
+ xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
return
item_count = 0
if len( trailers ) > 0:
check1 = re.compile( '<a href="(.+?)"><img
src="\/images\/usr\/arrow\.png" border="0" style="float:right;" \/>(.+?)</a>'
).findall( trailers[0] )
check2 = re.compile( '<a href="(.+?)"( style="(.*?)")?>(.+?)<br
/>' ).findall( trailers[0] )
- if len( check1 ) > 0:
+ totalItems = len( check1 )
+ totalItems2 = len( check2 )
+ if totalItems > 0:
url_title = check1
+ if library == True:
+ return url_title[0][0]
for url, title in url_title:
url = 'http://www.traileraddict.com' + url
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({
'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url,
'download': 'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ cm.append( (settings.getLocalizedString(30014),
"XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)"
% save_name) )
infoLabels = { "Title": title, "Plot":
save_name + ' (' + clean( title ) + ')' }
u = { 'mode': '5', 'name': save_name + ' (' +
clean( title ) + ')', 'url': url }
- addListItem(label = clean( title ), image =
thumb, url = u, isFolder = False, infoLabels = False)
+ addListItem(label = clean( title ), image =
thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False,
cm = cm)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]),
sortMethod = xbmcplugin.SORT_METHOD_NONE )
setViewMode("502", "movies")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
- elif len( check2 ) > 0:
+ elif totalItems2 > 0:
url_title = check2
+ if library == True:
+ return url_title[0][0]
for url, trash1, trash2, title in url_title:
url = 'http://www.traileraddict.com' + url
#infoLabels = { "Title": title, "Plot":
save_name + ' (' + clean( title ) + ')' }
- u = { 'mode': '5', 'name': save_name + ' (' +
clean( title ) + ')', 'url': url }
- addListItem(label = clean( title ), image =
thumb, url = u, isFolder = False, infoLabels = False)
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({
'mode': '5', 'name': save_name.decode('ascii', 'ignore') + ' (' + clean( title
) + ')', 'url': url, 'download': 'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ cm.append( (settings.getLocalizedString(30014),
"XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)"
% save_name.decode('ascii', 'ignore')) )
+ u = { 'mode': '5', 'name':
save_name.decode('ascii', 'ignore') + ' (' + clean( title ) + ')', 'url': url }
+ addListItem(label = clean( title ), image =
thumb, url = u, isFolder = False, totalItems = totalItems2, infoLabels = False,
cm = cm)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]),
sortMethod = xbmcplugin.SORT_METHOD_NONE )
setViewMode("502", "movies")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
else:
- dia = xbmcgui.Dialog()
- ok = dia.ok(plugin, settings.getLocalizedString(30006) )
- ok = dia.ok(plugin, settings.getLocalizedString( 30051
))
- buggalo.addExtraData('url', url)
- buggalo.addExtraData('name', save_name)
- raise Exception('find_trailers Error 2')
- return
+ # dia = xbmcgui.Dialog()
+ # ok = dia.ok(plugin,
settings.getLocalizedString(30006) )
+ # ok = dia.ok(plugin, settings.getLocalizedString(
30051 ))
+ # buggalo.addExtraData('url', url)
+ # buggalo.addExtraData('name', save_name)
+ # raise Exception('find_trailers Error 2')
+ # xbmc.executebuiltin('Notification('+plugin+',Only
video clips were found!,5000,'+icon_thumb+')')
+ list = common.parseDOM(data, "div", attrs = { "class":
"info" })
+ header = common.parseDOM(data, "div", attrs = {
"class": "trailerheader" })
+ nexturl = common.parseDOM(header, "a", attrs = {
"title": "Next Page" }, ret = "href")
+ totalItems = len(list)
+ if totalItems == 0:
+ dialog = xbmcgui.Dialog()
+ ok = dialog.ok(plugin,
settings.getLocalizedString( 30012 ))
+ ok = dialog.ok(plugin,
settings.getLocalizedString( 30051 ))
+ buggalo.addExtraData('url', url)
+ buggalo.addExtraData('name', name)
+ raise Exception('find_trailers Error B')
+ return
+ for video in list:
+ h2 = common.parseDOM(video, "h2")
+ title = common.parseDOM(h2, "a")[0]
+ url = 'http://www.traileraddict.com' +
common.parseDOM(h2, "a", ret = "href")[0]
+ thumb = 'http://www.traileraddict.com' +
common.parseDOM(video, "img", attrs = { "class": "dimmer" }, ret =
"src")[0].replace('-t.jpg','.jpg')
+ #infoLabels = { "Title": title, "Plot":
save_name + ' (' + clean( title ) + ')' }
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({
'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url,
'download': 'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ cm.append( (settings.getLocalizedString(30014),
"XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)"
% save_name) )
+ u = { 'mode': '5', 'name': save_name + ' (' +
clean( title ) + ')', 'url': url }
+ addListItem(label = clean( title ), image =
thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False,
cm = cm)
+ if len(nexturl) > 0:
+ url = 'http://www.traileraddict.com' +
nexturl[0]
+ u = { 'mode': '4', 'name': save_name, 'url':
url, 'page': str( int( save_page ) + 1 ) }
+ addListItem(label = '[Next Page (' + str( int(
save_page ) + 2 ) + ')]', image = next_thumb, url = u, isFolder = True,
totalItems = 0, infoLabels = False)
+ xbmcplugin.addSortMethod( handle = int(sys.argv[1]),
sortMethod = xbmcplugin.SORT_METHOD_NONE )
+ setViewMode("502", "movies")
+ xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
else:
+ totalItems = len(link_thumb)
for url, thumb2 in link_thumb:
if clean( title[item_count][1] ).find( 'Trailer' ) > 0:
url = 'http://www.traileraddict.com' + url
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({
'mode': '5', 'name': save_name + ' (' + clean( title[item_count][1] ) + ')',
'url': url, 'download': 'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ cm.append( (settings.getLocalizedString(30014),
"XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)"
% save_name) )
infoLabels = { "Title": title[item_count][1],
"Plot": save_name + ' (' + clean( title[item_count][1] ) + ')' }
u = { 'mode': '5', 'name': save_name + ' (' +
clean( title[item_count][1] ) + ')', 'url': url }
- addListItem(label = clean( title[item_count][1]
), image = thumb, url = u, isFolder = False, infoLabels = False)
+ addListItem(label = clean( title[item_count][1]
), image = thumb, url = u, isFolder = False, totalItems = totalItems,
infoLabels = False, cm = cm)
item_count = item_count + 1
xbmcplugin.addSortMethod( handle = int( sys.argv[1] ),
sortMethod = xbmcplugin.SORT_METHOD_NONE )
setViewMode("502", "movies")
@@ -96,14 +180,16 @@ def build_main_directory():
( settings.getLocalizedString(30001), film_reel_thumb, '1' ),
( settings.getLocalizedString(30002), clapperboard_thumb, '2' ),
( settings.getLocalizedString(30003), oscar_thumb, '3' ),
- ( settings.getLocalizedString(30004), popcorn_thumb, '6' )
+ ( settings.getLocalizedString(30004), popcorn_thumb, '6' ),
+ ( settings.getLocalizedString(30015), library_thumb, '7' )
]
for name, thumbnailImage, mode in main:
listitem = xbmcgui.ListItem( label = name, iconImage =
"DefaultVideo.png", thumbnailImage = thumbnailImage )
u = { 'mode': mode, 'name': name }
- addListItem(label = name, image = thumbnailImage, url = u,
isFolder = True, infoLabels = False)
+ addListItem(label = name, image = thumbnailImage, url = u,
isFolder = True, totalItems = 0, infoLabels = False)
data = getUrl( 'http://www.traileraddict.com' )
url_thumb_x_title = re.compile( '<a href="/trailer/(.+?)"><img
src="(.+?)" border="0" alt="(.+?)" title="(.+?)" style="margin:2px 10px 8px
10px;">' ).findall( data )
+ totalItems = len(url_thumb_x_title)
for url, thumb, x, title in url_thumb_x_title:
title = title.rsplit( ' - ' )
name1 = clean( title[0] )
@@ -113,35 +199,47 @@ def build_main_directory():
name2 = clean( title[0] )
url = 'http://www.traileraddict.com/trailer/' + url
thumb = 'http://www.traileraddict.com' + thumb
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5',
'name': name2, 'url': url, 'download': 'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ cm.append( (settings.getLocalizedString(30014),
"XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)"
% name1) )
u = { 'mode': '5', 'name': name2, 'url': url }
- addListItem(label = name1, image = thumb, url = u, isFolder =
False, infoLabels = False)
+ addListItem(label = name1, image = thumb, url = u, isFolder =
False, totalItems = totalItems, infoLabels = False, cm = cm)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
setViewMode("500", "movies")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@retry((IndexError, TypeError))
-def build_search_directory():
- keyboard = xbmc.Keyboard( '', settings.getLocalizedString(30007) )
- keyboard.doModal()
- if ( keyboard.isConfirmed() == False ):
- return
- search_string = keyboard.getText().replace( ' ', '+' )
- if len( search_string ) == 0:
- return
+def build_search_directory(name, url):
+ if url != 'library':
+ keyboard = xbmc.Keyboard( '',
settings.getLocalizedString(30007) )
+ keyboard.doModal()
+ if ( keyboard.isConfirmed() == False ):
+ return
+ search_string = keyboard.getText().replace( ' ', '+' )
+ if len( search_string ) == 0:
+ return
+ else:
+ search_string = name
data = getUrl( 'http://www.traileraddict.com/search.php?q=' +
search_string )
image = re.compile( '<center>\r\n<div style="background:url\((.*?)\);"
class="searchthumb">', re.DOTALL ).findall( data )
link_title = re.compile( '</div><a href="/tags/(.*?)">(.*?)</a><br />'
).findall( data )
if len( link_title ) == 0:
+ if url == 'library':
+ return None
dialog = xbmcgui.Dialog()
ok = dialog.ok( plugin , settings.getLocalizedString(30009) +
search_string + '.\n' + settings.getLocalizedString(30010) )
build_main_directory()
return
item_count=0
+ totalItems = len(link_title)
+ if url == 'library':
+ return link_title[0][0]
for url, title in link_title:
url = 'http://www.traileraddict.com/tags/' + url
thumb = 'http://www.traileraddict.com' +
image[item_count].replace( '/pthumb.php?dir=', '' ).replace( '\r\n', '' )
u = { 'mode': '4', 'name': clean( title ), 'url': url }
- addListItem(label = clean( title ), image = thumb, url = u,
isFolder = True, infoLabels = False)
+ addListItem(label = clean( title ), image = thumb, url = u,
isFolder = True, totalItems = totalItems, infoLabels = False)
item_count = item_count + 1
xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@@ -161,10 +259,11 @@ def build_film_database_directory():
build_main_directory()
return
item_count=0
+ totalItems = len(link_title)
for url, title in link_title:
url = 'http://www.traileraddict.com/' + url
u = { 'mode': '4', 'name': clean( title ), 'url': url }
- addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, infoLabels = False)
+ addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, totalItems = totalItems, infoLabels = False)
item_count = item_count + 1
xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@@ -176,17 +275,19 @@ def build_coming_soon_directory():
margin_left = re.compile( '<div style=\"float:left;
width:300px;(.*?)<div style="clear:both;">', re.DOTALL ).findall( data )[0]
link_title = re.compile( '<img src="/images/arrow2.png" class="arrow">
<a href="(.+?)">(.+?)</a>' ).findall( margin_left )
item_count = 0
+ totalItems = len(link_title)
for url, title in link_title:
url = 'http://www.traileraddict.com/' + url
u = { 'mode': '4', 'name': clean( title ), 'url': url }
- addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, infoLabels = False)
+ addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, totalItems = totalItems, infoLabels = False)
item_count = item_count + 1
link_title = re.compile( '<img src="/images/arrow2.png" class="arrow">
<a href="(.+?)">(.+?)</a>' ).findall( margin_right )
item_count = 0
+ totalItems = len(link_title)
for url, title in link_title:
url = 'http://www.traileraddict.com/' + url
u = { 'mode': '4', 'name': clean( title ), 'url': url }
- addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, infoLabels = False)
+ addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, totalItems = totalItems, infoLabels = False)
item_count = item_count + 1
xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@@ -201,8 +302,8 @@ def build_top_150_directory():
item_count = 0
title = link_title_views[item_count][1] + ' ' +
link_title_views[item_count][2]
url = 'http://www.traileraddict.com/' +
link_title_views[item_count][0]
- u = { 'mode': '4', 'name': clean( title ), 'url': url }
- addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, infoLabels = False)
+ u = { 'mode': '4', 'name': clean( title.rsplit(' (')[0] ),
'url': url }
+ addListItem(label = clean( title ), image = poster_thumb, url =
u, isFolder = True, totalItems = 150, infoLabels = False)
item_count = item_count + 1
xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@@ -212,6 +313,7 @@ def build_featured_directory( page ):
save_page = page
data = getUrl( 'http://www.traileraddict.com/attraction/' + str( int(
page ) + 1) )
url_thumb_x_title = re.compile( '<a href="/trailer/(.+?)"><img
src="(.+?)" border="0" alt="(.+?)" title="(.+?)" style="margin:8px 5px 2px
5px;"></a>' ).findall( data )
+ totalItems = len(url_thumb_x_title)
for url, thumb, x, title in url_thumb_x_title:
title = title.rsplit( ' - ' )
name1 = clean( title[0] )
@@ -221,16 +323,20 @@ def build_featured_directory( page ):
name2 = clean( title[0] )
url = 'http://www.traileraddict.com/trailer/' + url
thumb = 'http://www.traileraddict.com' + thumb
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5',
'name': name2, 'url': url, 'download': 'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ cm.append( (settings.getLocalizedString(30014),
"XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)"
% name1) )
u = { 'mode': '5', 'name': name2, 'url': url }
- addListItem(label = name1, image = thumb, url = u, isFolder =
False, infoLabels = False)
+ addListItem(label = name1, image = thumb, url = u, isFolder =
False, totalItems = totalItems, infoLabels = False, cm = cm)
u = { 'mode': '6', 'page': str( int( save_page ) + 1 ) }
- addListItem(label = '[ Next Page (' + str( int( save_page ) + 2 ) + ')
]', image = next_thumb, url = u, isFolder = True, infoLabels = False)
+ addListItem(label = '[ Next Page (' + str( int( save_page ) + 2 ) + ')
]', image = next_thumb, url = u, isFolder = True, totalItems = 0, infoLabels =
False)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
setViewMode("500", "movies")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@retry((IndexError, TypeError))
-def play_video( url, name ):
+def play_video( url, name, download ):
data = getUrl( url )
url = re.compile( '<param name="movie"
value="http://www.traileraddict.com/emb/(.+?)">' ).findall( data )[0]
if data.find( 'watchplus()' ) > 0:
@@ -239,6 +345,9 @@ def play_video( url, name ):
url = 'http://www.traileraddict.com/fvar.php?tid=' + url
data = getUrl( url )
thumb = re.compile( '&image=(.+?)&' ).findall( data )[0]
+ title = re.compile( '&filmtitle=(.+?)&' ).findall( data )
+ if len(title):
+ name = urllib.unquote_plus(title[0]) + ' (' +
settings.getLocalizedString(30017) + ')'
if thumb == 'http://www.traileraddict.com/images/noembed-removed.png':
dialog = xbmcgui.Dialog()
ok = dialog.ok(plugin, settings.getLocalizedString( 30012 ))
@@ -246,12 +355,87 @@ def play_video( url, name ):
url = re.compile( 'fileurl=(.+?)\n&vidwidth', re.DOTALL ).findall( data
)[0]
url = url.replace( '%3A', ':').replace( '%2F', '/' ).replace( '%3F',
'?' ).replace( '%3D', '=' ).replace( '%26', '&' ).replace( '%2F', '//' )
infoLabels = { "Title": name , "Studio": plugin }
- playListItem(label = name, image = xbmc.getInfoImage( "ListItem.Thumb"
), path = str(url), infoLabels = infoLabels, PlayPath = False)
+ if download == 'True':
+ start_download(name, str(url))
+ else:
+ playListItem(label = name, image = xbmc.getInfoImage(
"ListItem.Thumb" ), path = str(url), infoLabels = infoLabels, PlayPath = False)
+
+@retry(ValueError)
+def getMovieLibrary():
+ try:
+ if common.getXBMCVersion() >= 12.0:
+ properties = ['year', 'imdbnumber', 'thumbnail',
'plot', 'dateadded', 'rating']
+ else:
+ properties = ['year', 'imdbnumber', 'thumbnail',
'plot', 'rating']
+ except:
+ properties = ['year', 'imdbnumber', 'thumbnail', 'plot',
'rating']
+ rpccmd = json.dumps({'jsonrpc': '2.0', 'method':
'VideoLibrary.GetMovies', 'params':{'properties': properties, "sort": {
"order": "ascending", "method": "label", "ignorearticle": True } }, "id":
"libMovies"})
+ result = xbmc.executeJSONRPC(rpccmd)
+ result = json.loads(result)
+ if 'error' in result:
+ dialog = xbmcgui.Dialog()
+ ok = dialog.ok(plugin, settings.getLocalizedString( 30018 ))
+ build_main_directory()
+ return
+ if (result['result']['limits']['total'] == 0):
+ dialog = xbmcgui.Dialog()
+ ok = dialog.ok(plugin, settings.getLocalizedString( 30016 ))
+ build_main_directory()
+ return
+ totalItems = len(result['result']['movies'])
+ for movie in result['result']['movies']:
+ label = movie['label'].encode('ascii', 'ignore')
+ plot = movie['plot'].encode('ascii', 'ignore')
+ if 'dateadded' in movie:
+ day = movie['dateadded'].split(' ')[0].split('-')
+ date = day[2] + '.' + day[1] + '.' + day[0]
+ else:
+ date = '0000.00.00'
+ thumbnail = movie['thumbnail']
+ year = movie['thumbnail']
+ url = movie['imdbnumber'].rsplit('tt')
+ if len(url) == 2:
+ url = url[1]
+ else:
+ url = '1'
+ listitem = xbmcgui.ListItem( label = label, iconImage =
thumbnail, thumbnailImage = thumbnail )
+ u = { 'mode': '8', 'name': label, 'url': url }
+ cm = []
+ run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '8',
'name': label, 'url': url, 'download': 'True' })
+ cm.append( (settings.getLocalizedString(30059),
"XBMC.RunPlugin(%s)" % run) )
+ infoLabels = { "Title": label, "Plot": plot, "date": date,
"Year": movie['year'], "Rating": movie['rating'] }
+ addListItem(label = label, image = thumbnail, url = u, isFolder
= False, totalItems = totalItems, infoLabels = infoLabels, cm = cm)
+ xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_TITLE )
+ xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_DATE )
+ xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_VIDEO_YEAR )
+ xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_VIDEO_RATING )
+ setViewMode("500", "movies")
+ xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
+
+@retry(TypeError)
+def library_trailers( url, name, page, download ):
+ url = 'http://api.traileraddict.com/?imdb=' + url
+ data = getUrl( url )
+ slug = re.compile(
'<link>http:\/\/www\.traileraddict\.com\/trailer\/(.+?)\/' ).findall( data )
+ if len(slug):
+ slug = slug[0]
+ else:
+ slug = build_search_directory(name, 'library')
+ if slug == None:
+ dialog = xbmcgui.Dialog()
+ ok = dialog.ok(plugin, settings.getLocalizedString( 30019) +
name + '.')
+ return
+ url = 'http://www.traileraddict.com/tags/' + slug
+ url = find_trailers( url, name, page, True )
+ url = 'http://www.traileraddict.com' + url
+ play_video( url, name + ' (' + settings.getLocalizedString(30017) +
')', download )
params = getParameters(sys.argv[2])
url = None
name = None
mode = None
+download = None
+library = False
page = 0
try:
@@ -263,19 +447,23 @@ try:
except:
pass
try:
+ download = urllib.unquote_plus( params['download'] )
+except:
+ pass
+try:
mode = int( params['mode'] )
except:
pass
try:
- page = int( params['page'] )
+ page = int( params['page'] )
except:
- pass
+ pass
try:
if mode == None:
build_main_directory()
elif mode == 0:
- build_search_directory()
+ build_search_directory(name, url)
elif mode == 1:
build_film_database_directory()
elif mode == 2:
@@ -283,10 +471,14 @@ try:
elif mode == 3:
build_top_150_directory()
elif mode == 4:
- find_trailers( url, name )
+ find_trailers( url, name, page, library )
elif mode == 5:
- play_video( url, name )
+ play_video( url, name, download )
elif mode == 6:
build_featured_directory( page )
+ elif mode == 7:
+ getMovieLibrary()
+ elif mode == 8:
+ library_trailers( url, name, page, download )
except Exception:
buggalo.onExceptionRaised()
diff --git a/plugin.video.trailer.addict/resources/language/English/strings.xml
b/plugin.video.trailer.addict/resources/language/English/strings.xml
index 5bba63f..5cc120f 100644
--- a/plugin.video.trailer.addict/resources/language/English/strings.xml
+++ b/plugin.video.trailer.addict/resources/language/English/strings.xml
@@ -13,10 +13,21 @@
<string id="30011">Enter the film's starting letter, word, or release
year:</string>
<string id="30012">This video is currently not available.</string>
<string id="30013">Try searching for the movie.</string>
+ <string id="30014">Add Movie to CouchPotato</string>
+ <string id="30015">[ Library ]</string>
+ <string id="30016">No movies found in the Movie Library.</string>
+ <string id="30017">Trailer</string>
+ <string id="30018">There was an error accessing the Movie
Library.</string>
+ <string id="30019">No trailers found for </string>
+ <string id="30049">Enable Play All option</string>
<string id="30050">There was a connection error:</string>
<string id="30051">If this problem persists, please submit the error
report.</string>
<string id="30052">Retry</string>
<string id="30053">Quit</string>
<string id="30054">There was an index error.</string>
<string id="30055">Enable default view for Confluence skin</string>
+ <string id="30056">Always ask for download location</string>
+ <string id="30057">Default download location</string>
+ <string id="30058">Please set a default download location.</string>
+ <string id="30059">Download</string>
</strings>
diff --git a/plugin.video.trailer.addict/resources/settings.xml
b/plugin.video.trailer.addict/resources/settings.xml
index af726e2..739a23c 100644
--- a/plugin.video.trailer.addict/resources/settings.xml
+++ b/plugin.video.trailer.addict/resources/settings.xml
@@ -1,3 +1,5 @@
<settings>
<setting id="view" type="bool" label="30055" default="true"/>
+ <setting id="downloadPrompt" type="bool" label="30056" default="false"/>
+ <setting id="downloadPath" type="folder" label="30057" default="" />
</settings>
-----------------------------------------------------------------------
Summary of changes:
plugin.video.trailer.addict/addon.xml | 9 +-
plugin.video.trailer.addict/addonfunc.py | 60 ++++-
plugin.video.trailer.addict/changelog.txt | 7 +
plugin.video.trailer.addict/default.py | 292 ++++++++++++++++----
.../resources/language/English/strings.xml | 11 +
.../resources/media/library.png | Bin 51020 -> 51020 bytes
plugin.video.trailer.addict/resources/settings.xml | 2 +
7 files changed, 319 insertions(+), 62 deletions(-)
copy plugin.video.bliptv/thumbnails/movies.png =>
plugin.video.trailer.addict/resources/media/library.png (100%)
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons