本文整理汇总了Python中xbmc.getCacheThumbName函数的典型用法代码示例。如果您正苦于以下问题:Python getCacheThumbName函数的具体用法?Python getCacheThumbName怎么用?Python getCacheThumbName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCacheThumbName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _shuffle_trailers
def _shuffle_trailers( self ):
# randomize the groups and create our play list
shuffle( self.tmp_trailers )
# reset counter
count = 0
# now create our final playlist
for trailer in self.tmp_trailers:
# user preference to skip watch trailers
if ( self.settings[ "trailer_unwatched_only" ] and xbmc.getCacheThumbName( trailer[ 0 ] ) in self.watched ):
##print "SKIPPED:", repr(trailer[ 0 ])
continue
# set all info
tmp_trailer = self._set_trailer_info( trailer )
# convert mpaa if necessary
if ( self.mpaa_conversion is not None ):
tmp_trailer[ 6 ] = self.mpaa_conversion.get( tmp_trailer[ 6 ], "NR" )
# do we need to skip this one
if ( self.mpaa_ratings.get( self.mpaa, self.settings[ "unrated_rating_index" ] ) < self.mpaa_ratings.get( tmp_trailer[ 6 ], self.settings[ "unrated_rating_index" ] ) ):
##LOG( "Skipping trailer: %s - Movie: %s, Unrated: %s, Trailer: %s" % ( repr( tmp_trailer[ 1 ] ), self.mpaa, ("G","PG","PG-13","R","NC-17",)[ self.settings[ "mpaa_rating" ] ], tmp_trailer[ 6 ], ) )
continue
# add id to watched file
if ( self.settings[ "trailer_unwatched_only" ] ):
self.watched += [ xbmc.getCacheThumbName( trailer[ 0 ] ) ]
# add trailer to our final list
self.trailers += [ tmp_trailer ]
# increment counter
count += 1
# if we have enough exit
if ( count == self.settings[ "trailer_count" ] ):
break
示例2: _shuffle_slides
def _shuffle_slides( tmp_slides, watched ):
utils.log( "Sorting Watched/Unwatched and Shuffing Slides ", xbmc.LOGNOTICE )
slide_playlist = []
# randomize the groups and create our play list
count = 0
while count <6:
shuffle( tmp_slides, random )
count += 1
# now create our final playlist
# loop thru slide groups and skip already watched groups
for slides in tmp_slides:
# has this group been watched
if ( not slide_settings[ "trivia_unwatched_only" ] or ( slides[ 0 ] and xbmc.getCacheThumbName( slides[ 0 ] ) not in watched ) or
( slides[ 1 ] and xbmc.getCacheThumbName( slides[ 1 ] ) not in watched ) or
( slides[ 2 ] and xbmc.getCacheThumbName( slides[ 2 ] ) not in watched ) ):
# loop thru slide group only include non blank slides
for slide in slides:
# only add if non blank
if ( slide ):
# add slide
slide_playlist += [ slide ]
utils.log( "-------- Unwatched -------- included - %s, %s, %s" % ( os.path.basename( slides[ 0 ] ), os.path.basename( slides[ 1 ] ), os.path.basename( slides[ 2 ] ), ) )
else:
utils.log( "-------- Watched -------- skipped - %s, %s, %s" % ( os.path.basename( slides[ 0 ] ), os.path.basename( slides[ 1 ] ), os.path.basename( slides[ 2 ] ), ) )
utils.log( "-----------------------------" )
utils.log( "Total slides selected: %d" % len( slide_playlist ), xbmc.LOGNOTICE )
# reset watched automatically if no slides are left
if ( len( slide_playlist ) == 0 and slide_settings[ "trivia_unwatched_only" ] and len( watched ) > 0 ):
watched = _reset_watched()
#attempt to load our playlist again
_shuffle_slides( tmp_slides, watched )
return slide_playlist
示例3: _shuffle_trailers
def _shuffle_trailers( self ):
# randomize the groups and create our play list
utils.log( "Shuffling Trailers", xbmc.LOGNOTICE )
shuffle( self.tmp_trailers )
count = 0
# now create our final playlist
for trailer in self.tmp_trailers:
# user preference to skip watch trailers
if ( self.settings[ "trailer_unwatched_only" ] and xbmc.getCacheThumbName( trailer ) in self.watched ):
continue
# add trailer to our final list
trailer_info = _set_trailer_info( trailer )
trailer_genre = trailer_info[ 9 ].split(" / ")
trailer_rating = trailer_info[ 6 ].replace("Rated ", "")
if self.settings[ "trailer_limit_genre" ]:
if len( set( trailer_genre ).intersection( self.genre ) ) < 1:
utils.log("Genre Not Matched - Skipping Trailer: %s != %s" % (trailer_genre, self.genre) )
continue
if self.settings[ "trailer_limit_mpaa" ]:
trailer_mpaa = self.mpaa_ratings.index( trailer_rating )
if trailer_mpaa > self.mpaa:
utils.log("MPAA too high - Skipping Trailer: %s > %s" % ( trailer_rating, self.mpaa_ratings[ self.mpaa ] ) )
continue
self.trailers += [ trailer_info ]
# add id to watched file TODO: maybe don't add if not user preference
self.watched += [ xbmc.getCacheThumbName( trailer ) ]
# increment counter
count += 1
# if we have enough exit
if ( count == self.settings[ "trailer_count" ] ):
break
if ( len( self.trailers ) == 0 and self.settings[ "trailer_unwatched_only" ] and len( self.watched ) > 0 ):
self._reset_watched()
#attempt to load our playlist again
self._shuffle_trailers()
示例4: _shuffle_trailers
def _shuffle_trailers( self ):
# randomize the groups and create our play list
log( "%s - Shuffling Trailers" % logmessage, xbmc.LOGNOTICE )
shuffle( self.tmp_trailers )
# reset counter
count = 0
# now create our final playlist
for trailer in self.tmp_trailers:
# user preference to skip watch trailers
if ( self.settings[ "trailer_unwatched_only" ] and xbmc.getCacheThumbName( trailer ) in self.watched ):
continue
# add trailer to our final list
trailer_info = _set_trailer_info( trailer )
trailer_genre = trailer_info[ 9 ].split(" / ")
trailer_rating = trailer_info[ 6 ].replace("Rated ", "")
if self.settings[ "trailer_limit_genre" ] and ( not list(set(trailer_genre) & set(self.genre) ) ):
log( "%s - Genre Not Matched - Skipping Trailer" % logmessage )
continue
if self.settings[ "trailer_limit_mpaa" ] and ( not trailer_rating or not trailer_rating == self.mpaa ):
log( "%s - MPAA Not Matched - Skipping Trailer" % logmessage )
continue
self.trailers += [ trailer_info ]
# add id to watched file TODO: maybe don't add if not user preference
self.watched += [ xbmc.getCacheThumbName( trailer ) ]
# increment counter
count += 1
# if we have enough exit
if ( count == self.settings[ "trailer_count" ] ):
break
if ( len(self.trailers) == 0 and self.settings[ "trailer_unwatched_only" ] and len( self.watched ) > 0 ):
self._reset_watched()
#attempt to load our playlist again
self._shuffle_trailers()
示例5: getCachedThumb
def getCachedThumb(file):
if file[0:8] == 'stack://':
commaPos = file.find(' , ')
file = xbmc.getCacheThumbName(file[8:commaPos].strip())
crc = xbmc.getCacheThumbName(file.lower())
return xbmc.translatePath('special://profile/Thumbnails/Video/%s/%s' % (crc[0], crc))
示例6: _shuffle_slides
def _shuffle_slides( self ):
# randomize the groups and create our play list
shuffle( self.tmp_slides )
# now create our final playlist
print "-----------------------------------------"
# loop thru slide groups and skip already watched groups
for slides in self.tmp_slides:
# has this group been watched
if ( not self.settings[ "trivia_unwatched_only" ] or ( slides[ 0 ] and xbmc.getCacheThumbName( slides[ 0 ] ) not in self.watched ) or
( slides[ 1 ] and xbmc.getCacheThumbName( slides[ 1 ] ) not in self.watched ) or
( slides[ 2 ] and xbmc.getCacheThumbName( slides[ 2 ] ) not in self.watched ) ):
# loop thru slide group only include non blank slides
for slide in slides:
# only add if non blank
if ( slide ):
# add slide
self.slide_playlist += [ slide ]
print "included - %s, %s, %s" % ( os.path.basename( slides[ 0 ] ), os.path.basename( slides[ 1 ] ), os.path.basename( slides[ 2 ] ), )
else:
print "----------------------------------------------------"
print "skipped - %s, %s, %s" % ( os.path.basename( slides[ 0 ] ), os.path.basename( slides[ 1 ] ), os.path.basename( slides[ 2 ] ), )
print "----------------------------------------------------"
print
print "total slides selected: %d" % len( self.slide_playlist )
print
示例7: getCacheThumb
def getCacheThumb( self, path, file ):
play_path = fanart_path = thumb_path = path + file
if ( file.startswith( "stack://" ) ):
play_path = fanart_path = file
thumb_path = file[ 8 : ].split( " , " )[ 0 ]
if ( file.startswith( "rar://" ) or file.startswith( "zip://" ) ):
play_path = fanart_path = thumb_path = file
return xbmc.getCacheThumbName( thumb_path ), xbmc.getCacheThumbName( fanart_path ), play_path
示例8: PrepareCacheDirs
def PrepareCacheDirs(self, item):
chandirname = xbmc.getCacheThumbName(item.channel.link).replace(".tbn","")
tpath = xbmc.translatePath('special://masterprofile/Thumbnails/RSS/%s' % chandirname)
checkDir(tpath)
itemdirname = xbmc.getCacheThumbName(item.link).replace(".tbn","")
tpath = os.path.join(tpath, itemdirname)
checkDir(tpath)
item.multiimagepath = tpath
示例9: _fetch_music_info
def _fetch_music_info( self ):
# Current Working Directory
# sql statement
if ( self.ALBUMS ):
sql_music = "select * from albumview order by RANDOM() limit %d" % ( self.LIMIT, )
# query the database for recently added albums
music_xml = xbmc.executehttpapi( "QueryMusicDatabase(%s)" % quote_plus( sql_music ), )
# separate the records
items = re.findall( "<record>(.+?)</record>", music_xml, re.DOTALL )
# enumerate thru our records and set our properties
for count, item in enumerate( items ):
# separate individual fields
fields = re.findall( "<field>(.*?)</field>", item, re.DOTALL )
# set properties
self.WINDOW.setProperty( "RandomSong.%d.Title" % ( count + 1, ), fields[ 1 ] )
self.WINDOW.setProperty( "RandomSong.%d.Year" % ( count + 1, ), fields[ 8 ] )
self.WINDOW.setProperty( "RandomSong.%d.Artist" % ( count + 1, ), fields[ 6 ] )
self.WINDOW.setProperty( "RandomSong.%d.Rating" % ( count + 1, ), fields[ 18 ] )
# Album Path (ID)
path = 'XBMC.RunScript(script.randomitems,albumid=' + fields[ 0 ] + ')'
self.WINDOW.setProperty( "RandomSong.%d.Path" % ( count + 1, ), path )
# get cache name of path to use for fanart
cache_name = xbmc.getCacheThumbName( fields[ 6 ] )
self.WINDOW.setProperty( "RandomSong.%d.Fanart" % ( count + 1, ), "special://profile/Thumbnails/Music/%s/%s" % ( "Fanart", cache_name, ) )
self.WINDOW.setProperty( "RandomSong.%d.Thumb" % ( count + 1, ), fields[ 9 ] )
else:
# set our unplayed query
unplayed = ( "", "where lastplayed is null ", )[ self.UNPLAYED ]
# sql statement
sql_music = "select * from songview %sorder by RANDOM() limit %d" % ( unplayed, self.LIMIT, )
# query the database
music_xml = xbmc.executehttpapi( "QueryMusicDatabase(%s)" % quote_plus( sql_music ), )
# separate the records
items = re.findall( "<record>(.+?)</record>", music_xml, re.DOTALL )
# enumerate thru our records and set our properties
for count, item in enumerate( items ):
# separate individual fields
fields = re.findall( "<field>(.*?)</field>", item, re.DOTALL )
# set properties
self.WINDOW.setProperty( "RandomSong.%d.Title" % ( count + 1, ), fields[ 3 ] )
self.WINDOW.setProperty( "RandomSong.%d.Year" % ( count + 1, ), fields[ 6 ] )
self.WINDOW.setProperty( "RandomSong.%d.Artist" % ( count + 1, ), fields[ 24 ] )
self.WINDOW.setProperty( "RandomSong.%d.Album" % ( count + 1, ), fields[ 21 ] )
self.WINDOW.setProperty( "RandomSong.%d.Rating" % ( count + 1, ), fields[ 18 ] )
path = fields[ 22 ]
# don't add song for albums list TODO: figure out how toplay albums
##if ( not self.ALBUMS ):
path += fields[ 8 ]
self.WINDOW.setProperty( "RandomSong.%d.Path" % ( count + 1, ), path )
# get cache name of path to use for fanart
cache_name = xbmc.getCacheThumbName( fields[ 24 ] )
self.WINDOW.setProperty( "RandomSong.%d.Fanart" % ( count + 1, ), "special://profile/Thumbnails/Music/%s/%s" % ( "Fanart", cache_name, ) )
self.WINDOW.setProperty( "RandomSong.%d.Thumb" % ( count + 1, ), fields[ 27 ] )
示例10: _get_media
def _get_media( self, path, file ):
# set default values
play_path = fanart_path = thumb_path = path + file
# we handle stack:// media special
if ( file.startswith( "stack://" ) ):
play_path = fanart_path = file
thumb_path = file[ 8 : ].split( " , " )[ 0 ]
# we handle rar:// and zip:// media special
if ( file.startswith( "rar://" ) or file.startswith( "zip://" ) ):
play_path = fanart_path = thumb_path = file
# strip username/password
return xbmc.getCacheThumbName( re.sub( "//[email protected]", "//", thumb_path ) ), xbmc.getCacheThumbName( re.sub( "//[email protected]", "//", fanart_path ) ), play_path
示例11: _get_media
def _get_media( self, path, file ):
# set default values
play_path = fanart_path = thumb_path = path + file
# we handle stack:// media special
if ( file.startswith( "stack://" ) ):
play_path = fanart_path = file
thumb_path = file[ 8 : ].split( " , " )[ 0 ]
# we handle rar:// and zip:// media special
if ( file.startswith( "rar://" ) or file.startswith( "zip://" ) ):
play_path = fanart_path = thumb_path = file
# return media info
return xbmc.getCacheThumbName( thumb_path ), xbmc.getCacheThumbName( fanart_path ), play_path
示例12: get_cached_thumb
def get_cached_thumb(self, filename):
if filename.startswith("stack://"):
filename = strPath[ 8 : ].split(" , ")[ 0 ]
if filename.endswith("folder.jpg"):
cachedthumb = xbmc.getCacheThumbName(filename)
thumbpath = os.path.join( THUMBS_CACHE_PATH, cachedthumb[0], cachedthumb ).replace( "/Video" , "")
else:
cachedthumb = xbmc.getCacheThumbName(filename)
if ".jpg" in filename:
cachedthumb = cachedthumb.replace("tbn" ,"jpg")
elif ".png" in filename:
cachedthumb = cachedthumb.replace("tbn" ,"png")
thumbpath = os.path.join( THUMBS_CACHE_PATH, cachedthumb[0], cachedthumb ).replace( "/Video" , "")
return thumbpath
示例13: get_path
def get_path( self, pack_type, icon ):
if ( pack_type == "scripts" ):
path = xbmc.translatePath( os.path.join( "Q:\\%s" % pack_type, icon + "\\" ) )
cached_thumbnail = xbmc.getCacheThumbName( os.path.join( path, "default.py" ) )
if ( os.path.isdir( path ) ):
return path, cached_thumbnail, None
else:
for source in ( "video", "music", "pictures", "programs", ):
path = xbmc.translatePath( os.path.join( "Q:\\%s" % pack_type, source, icon + "\\" ) )
cached_thumbnail = xbmc.getCacheThumbName( path )
root_cached_thumbnail = xbmc.getCacheThumbName( "plugin://video/" + icon + "/" )
if ( os.path.isdir( path ) ):
return path, cached_thumbnail, root_cached_thumbnail
return None, None, None
示例14: move_movie
def move_movie(self, movie, old_path, new_path):
## Update file with new id
# Create query
query = "UPDATE files \
SET idPath=? \
WHERE idFile=?"
# Create values
value = new_path.meta, movie.meta
# Create a cursor
c = self.db.create_cursor()
# Launch query
c.execute(query, value)
### Move file
## Get filename
# Create query
query = "SELECT f.strFilename \
FROM files f \
WHERE f.idFile = ?"
# Create values
value = (movie.meta,)
# Launch query
c.execute(query, value)
# Build result
mfile = unicode(c.fetchone()[0])
# mfile = unicode( c.fetchone()[0] )
## Deal with stacked files
if mfile.startswith("stack://"):
logging.dbg("Dealing with stacked files")
# Update db file with new values
query = "UPDATE files \
SET strFilename=? WHERE idFile=?"
# Create values
strfn = mfile.replace(old_path, new_path)
value = strfn, movie.meta
# Launch query
c.execute(query, value)
# Get fanart cache filename and move it
srcfn = xbmc.translatePath("special://thumbnails/Video") + "/Fanart/" + xbmc.getCacheThumbName(mfile)
dstfn = xbmc.translatePath("special://thumbnails/Video") + "/Fanart/" + xbmc.getCacheThumbName(strfn)
try:
shutil.move(srcfn, dstfn)
logging.dbg("move %s %s" % (srcfn, dstfn))
except IOError, e:
logging.err("Error moving %s %s: %s" % (srcfn, dstfn, e))
pass
# Create file list with removed whites spaces arround names
mfiles = map(lambda x: x.strip(), mfile[8:].split(","))
示例15: run
def run(self):
cachedthumb = xbmc.getCacheThumbName(self.url)
xbmc_cache_file = os.path.join(xbmc.translatePath("special://profile/Thumbnails/Video"), cachedthumb[0], cachedthumb)
if xbmcvfs.exists(xbmc_cache_file):
log("Cached Image: " + self.url)
return xbmc_cache_file
else:
try:
log("Download: " + self.url)
request = urllib2.Request(self.url)
request.add_header('Accept-encoding', 'gzip')
response = urllib2.urlopen(request)
data = response.read()
response.close()
log('image downloaded')
except:
log('image download failed')
return ""
if data != '':
try:
tmpfile = open(xbmc_cache_file, 'wb')
tmpfile.write(data)
tmpfile.close()
return xbmc_cache_file
except:
log('failed to save image')
return ""
else:
return ""