本文整理汇总了Python中xbmc.getSupportedMedia函数的典型用法代码示例。如果您正苦于以下问题:Python getSupportedMedia函数的具体用法?Python getSupportedMedia怎么用?Python getSupportedMedia使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSupportedMedia函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_music_playlist
def build_music_playlist():
log( "Building Music Playlist", xbmc.LOGNOTICE )
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.Clear", "id": 1}')
music_playlist = xbmc.PlayList( xbmc.PLAYLIST_MUSIC )
track_location = []
# check to see if playlist or music file is selected
if trivia_settings[ "trivia_music" ] == 1:
if trivia_settings[ "trivia_music_file" ].endswith(".m3u"):
log( "Music Playlist: %s" % trivia_settings[ "trivia_music_file" ] )
playlist_file = xbmcvfs.File( trivia_settings[ "trivia_music_file" ], 'rb')
saved_playlist = playlist_file.read().splitlines()
playlist_file.close()
log( "Finished Reading Music Playlist" )
track_info, track_location = parse_playlist( saved_playlist, xbmc.getSupportedMedia('music') )
elif os.path.splitext( trivia_settings[ "trivia_music_file" ] )[1] in xbmc.getSupportedMedia('music'):
for track in range(100):
track_location.append( trivia_settings[ "trivia_music_file" ] )
# otherwise
else:
if trivia_settings[ "trivia_music_folder" ]:
# search given folder and subfolders for files
track_location = dirEntries( trivia_settings[ "trivia_music_folder" ], "music", "TRUE" )
# shuffle playlist
shuffle( track_location )
for track in track_location:
music_playlist.add( track, )
示例2: build_music_playlist
def build_music_playlist():
xbmc.log( "%s - Building Music Playlist" % log_message, level=xbmc.LOGNOTICE)
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.Clear", "id": 1}')
music_playlist = xbmc.PlayList( xbmc.PLAYLIST_MUSIC )
track_location = []
# check to see if playlist or music file is selected
if int( _S_( "trivia_music" ) ) == 1:
if _S_( "trivia_music_file" ).endswith(".m3u"):
xbmc.log( "%s - Music Playlist: %s" % ( log_message, _S_( "trivia_music_file" ) ), level=xbmc.LOGDEBUG)
playlist_file = open( _S_( "trivia_music_file" ), 'rb')
saved_playlist = playlist_file.readlines()
xbmc.log( "%s - Finished Reading Music Playlist" % log_message, level=xbmc.LOGDEBUG)
track_info, track_location = parse_playlist( saved_playlist, xbmc.getSupportedMedia('music') )
elif os.path.splitext( _S_( "trivia_music_file" ) )[1] in xbmc.getSupportedMedia('music'):
for track in range(100):
track_location.append( _S_( "trivia_music_file" ) )
# otherwise
else:
if _S_( "trivia_music_folder" ):
# search given folder and subfolders for files
track_location = dirEntries( _S_( "trivia_music_folder" ), "music", "TRUE" )
# shuffle playlist
count = 0
while count <6:
shuffle( track_location, random )
count+=1
for track in track_location:
music_playlist.add( track, )
示例3: _validateExtension
def _validateExtension(ext,info):
#use Kodi's supported media to check for valid extension or return default
if info.get('media_type') == 'video':
if not ext in xbmc.getSupportedMedia('video'): return 'mp4'
elif info.get('media_type') == 'audio':
if not ext in xbmc.getSupportedMedia('music'): return 'mp3'
elif info.get('media_type') == 'image':
if not ext in xbmc.getSupportedMedia('picture'): return 'jpg'
return ext
示例4: _isValidMediaExtension
def _isValidMediaExtension(ext):
# use Kodi's supported media to check for valid extension
if (
ext in xbmc.getSupportedMedia("video")
or ext in xbmc.getSupportedMedia("music")
or ext in xbmc.getSupportedMedia("picture")
):
return True
return False
示例5: getTypeFromExt
def getTypeFromExt(ext):
ext = ext.lower()
video = xbmc.getSupportedMedia('video').replace('.','').split('|')
audio = xbmc.getSupportedMedia('music').replace('.','').split('|')
image = xbmc.getSupportedMedia('picture').replace('.','').split('|')
if ext in video:
return 'videofile'
elif ext in audio:
return 'audiofile'
elif ext in image:
return 'imagefile'
return None
示例6: _validateExtension
def _validateExtension(ext, info):
# use Kodi's supported media to check for valid extension or return default
if info.get("media_type") == "video":
if ext not in xbmc.getSupportedMedia("video"):
return "mp4"
elif info.get("media_type") == "audio":
if ext not in xbmc.getSupportedMedia("music"):
return "mp3"
elif info.get("media_type") == "image":
if ext not in xbmc.getSupportedMedia("picture"):
return "jpg"
return ext
示例7: getURLMediaType
def getURLMediaType(url):
if url.startswith("http"):
videoTypes = xbmc.getSupportedMedia("video")
musicTypes = xbmc.getSupportedMedia("music")
imageTypes = xbmc.getSupportedMedia("picture")
ext = url.rsplit(".", 1)[-1]
if ext in videoTypes:
return "video"
elif ext in musicTypes:
return "audio"
elif ext in imageTypes:
return "image"
return protocolMediaType(url)
示例8: getURLMediaType
def getURLMediaType(url):
if url.startswith('http'):
videoTypes = xbmc.getSupportedMedia('video')
musicTypes = xbmc.getSupportedMedia('music')
imageTypes = xbmc.getSupportedMedia('picture')
ext = url.rsplit('.',1)[-1]
if ext in videoTypes:
return 'video'
elif ext in musicTypes:
return 'audio'
elif ext in imageTypes:
return 'image'
return protocolMediaType(url)
示例9: _get_slides
def _get_slides( paths, movie_mpaa ):
# reset folders list
tmp_slides = []
folders = []
# mpaa ratings
mpaa_ratings = { "G": 0, "PG": 1, "PG-13": 2, "R": 3, "NC-17": 4, "--": 5, "": 6 }
# enumerate thru paths and fetch slides recursively
for path in paths:
# get the directory listing
entries = dirEntries( path, media_type="files", recursive="FALSE" )
# sort in case
entries.sort()
# get a slides.xml if it exists
slidesxml_exists, mpaa, question_format, clue_format, answer_format, still_format = _get_slides_xml( path )
# check if rating is ok
log( "Movie MPAA: %s" % movie_mpaa )
log( "Slide MPAA: %s" % mpaa )
if ( slidesxml_exists and mpaa_ratings.get( movie_mpaa, -1 ) < mpaa_ratings.get( mpaa, -1 ) ):
log( "Slide Rating above movie rating - skipping whole folder", xbmc.LOGNOTICE )
continue
# initialize these to True so we add a new list item to start
question = clue = answer = still = True
# enumerate through our entries list and combine question, clue, answer
for entry in entries:
# if folder add to our folder list to recursively fetch slides
if ( entry.endswith( "/" ) or entry.endswith( "\\" ) ):
folders += [ entry ]
# sliders.xml was included, so check it
elif ( slidesxml_exists ):
# question
if ( question_format and re.search( question_format, os.path.basename( entry ), re.IGNORECASE ) ):
if ( question ):
tmp_slides += [ [ "", "", "" ] ]
clue = answer = still = False
tmp_slides[ -1 ][ 0 ] = "__question__" + entry
# clue
elif ( clue_format and re.search( clue_format, os.path.basename( entry ), re.IGNORECASE ) ):
if ( clue ):
tmp_slides += [ [ "", "", "" ] ]
question = answer = still = False
tmp_slides[ -1 ][ 1 ] = "__clue__" + entry
# answer
elif ( answer_format and re.search( answer_format, os.path.basename( entry ), re.IGNORECASE ) ):
if ( answer ):
tmp_slides += [ [ "", "", "" ] ]
question = clue = still = False
tmp_slides[ -1 ][ 2 ] = "__answer__" + entry
# still
elif ( still_format and re.search( still_format, os.path.basename( entry ), re.IGNORECASE ) ):
if ( still ):
tmp_slides += [ [ "", "", "" ] ]
clue = answer = question = False
tmp_slides[ -1 ][ 0 ] = "__still__" + entry
# add the file as a question TODO: maybe check for valid picture format?
elif ( entry and os.path.splitext( entry )[ 1 ].lower() in xbmc.getSupportedMedia( "picture" ) ):
tmp_slides += [ [ "", "", "__still__" + entry ] ]
# if there are folders call again (we want recursive)
if ( folders ):
tmp_slides.extend( _get_slides( folders, movie_mpaa ) )
return tmp_slides
示例10: build_music_playlist
def build_music_playlist():
utils.log( "Building Music Playlist", xbmc.LOGNOTICE )
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioPlaylist.Clear", "id": 1}')
music_playlist = xbmc.PlayList( xbmc.PLAYLIST_MUSIC )
track_location = []
# check to see if playlist or music file is selected
if trivia_settings[ "trivia_music" ] == 1:
if ( os.path.splitext( trivia_settings[ "trivia_music_file" ] )[ 1 ] ).lower() in ( "m3u", "pls", "asf", "ram" ):
utils.log( "Music Playlist: %s" % trivia_settings[ "trivia_music_file" ] )
if trivia_settings[ "trivia_music_file" ].endswith(".m3u"):
track_location = parser.parse_m3u( trivia_settings[ "trivia_music_file" ], xbmc.getSupportedMedia('music') )
elif trivia_settings[ "trivia_music_file" ].endswith(".pls"):
track_location = parser.parse_pls( trivia_settings[ "trivia_music_file" ], xbmc.getSupportedMedia('music') )
elif trivia_settings[ "trivia_music_file" ].endswith(".asf"):
track_location = parser.parse_asf( trivia_settings[ "trivia_music_file" ], xbmc.getSupportedMedia('music') )
elif trivia_settings[ "trivia_music_file" ].endswith(".ram"):
track_location = parser.parse_ram( trivia_settings[ "trivia_music_file" ], xbmc.getSupportedMedia('music') )
elif os.path.splitext( trivia_settings[ "trivia_music_file" ] )[1] in xbmc.getSupportedMedia('music'):
for track in range(100):
track_location.append( trivia_settings[ "trivia_music_file" ] )
# otherwise
else:
if trivia_settings[ "trivia_music_folder" ]:
# search given folder and subfolders for files
track_location = absolute_listdir( trivia_settings[ "trivia_music_folder" ], media_type = "music", recursive = True )
# shuffle playlist
shuffle( track_location )
for track in track_location:
music_playlist.add( track, )
示例11: _get_items
def _get_items(self, paths, media_type):
# reset folders list
folders = []
# enumerate thru paths and fetch videos/pictures recursively
for path in paths:
# get the directory listing
entries = xbmc.executehttpapi("GetDirectory(%s)" % (path,)).split("\n")
# enumerate through our entries list and check for valid media type
for entry in entries:
# remove <li> from item
entry = entry.replace("<li>", "")
# if folder add to our folder list to recursively fetch videos/pictures
if entry.endswith("/") or entry.endswith("\\"):
folders += [entry]
# is this a valid video/picture file
elif entry and (
(media_type.startswith("video") and os.path.splitext(entry)[1] in xbmc.getSupportedMedia("video"))
or (
media_type.endswith("picture")
and os.path.splitext(entry)[1] in xbmc.getSupportedMedia("picture")
)
):
# add our entry
self.tmp_paths += [entry]
# if there are folders call again (we want recursive)
if folders:
self._get_items(folders, media_type)
示例12: absolute_listdir
def absolute_listdir( path, media_type = "files", recursive = False, contains = "" ):
absolute_files = []
absolute_folders = []
path = utils.smart_unicode( path )
folders, files = xbmcvfs.listdir( path )
for f in files:
f = utils.smart_unicode( f )
if media_type == "files":
if not contains or ( contains and ( contains in f ) ):
try:
absolute_files.append( os.path.join( path, f ).replace("\\\\","\\") )
except UnicodeError:
utils.log( "Problem with path, skipping" )
utils.log( "Path: %s" % repr( path ) )
utils.log( "Filename: %s" % repr( path ) )
except:
utils.log( "Problem with path, skipping" )
traceback.print_exc()
else:
if ( os.path.splitext( f )[ 1 ] ).lower() in ( xbmc.getSupportedMedia( media_type ) ).lower():
if not contains or ( contains and ( contains in f ) ):
absolute_files.append( os.path.join( path, f ).replace("\\\\","\\") )
if folders:
absolute_folders = absolute_folder_paths( folders, path )
if recursive:
for folder in absolute_folders:
absolute_files.extend( absolute_listdir( folder, media_type = media_type, recursive = recursive, contains = contains ) )
return absolute_files
示例13: get_user_input
def get_user_input(self, itype, header, *args):
"""Get user input of type defined by 'itype'."""
if itype == 'string':
v = self.__get_from_keyboard(header)
elif itype == 'directory':
#v = os.getcwd()
dialog = xbmcgui.Dialog()
v = dialog.browse(3, header, 'files')
elif itype == 'picture':
mask = xbmc.getSupportedMedia('picture')
mltp = False
if len(args):
mltp = args[0]
dialog = xbmcgui.Dialog()
# first testing if multiple selection patch is applied to FileBrowser,
# otherwise fall back to old method call, but return tuple anyway.
# required patch: http://trac.xbmc.org/ticket/10894
# available since git commit dcad8dbd
try:
v = dialog.browse(2, header, "pictures", mask, False, False, mltp)
except TypeError:
v = dialog.browse(2, header, "pictures", mask)
v = (v,)
elif itype == 'select':
dialog = xbmcgui.Dialog()
v = dialog.select(header, *args)
elif itype == 'number':
v = xbmcgui.Dialog().numeric(0, header)
else:
v = None
return v
示例14: _get_slides
def _get_slides( paths, movie_mpaa ):
# reset folders list
tmp_slides = []
folders = []
# mpaa ratings
mpaa_ratings = { "G": 0, "PG": 1, "PG-13": 2, "R": 3, "NC-17": 4, "--": 5, "": 6 }
# enumerate thru paths and fetch slides recursively
for path in paths:
# get the directory listing
entries = xbmc.executehttpapi( "GetDirectory(%s)" % ( path, ) ).split( "\n" )
# sort in case
entries.sort()
# get a slides.xml if it exists
slidesxml_exists, mpaa, question_format, clue_format, answer_format = _get_slides_xml( path )
# check if rating is ok
xbmc.log( "[script.cinema.experience] - Movie MPAA: %s" % movie_mpaa, level=xbmc.LOGDEBUG )
xbmc.log( "[script.cinema.experience] - Slide MPAA: %s" % mpaa, level=xbmc.LOGDEBUG )
if ( slidesxml_exists and mpaa_ratings.get( movie_mpaa, -1 ) < mpaa_ratings.get( mpaa, -1 ) ):
xbmc.log( "[script.cinema.experience] - Slide Rating above movie rating - skipping whole folder", level=xbmc.LOGNOTICE)
continue
# initialize these to True so we add a new list item to start
question = clue = answer = True
# enumerate through our entries list and combine question, clue, answer
for entry in entries:
# remove <li> from item
entry = entry.replace( "<li>", "" )
# if folder add to our folder list to recursively fetch slides
if ( entry.endswith( "/" ) or entry.endswith( "\\" ) ):
folders += [ entry.replace( "<li>", "" ) ]
# sliders.xml was included, so check it
elif ( slidesxml_exists ):
# question
if ( question_format and re.search( question_format, os.path.basename( entry ), re.IGNORECASE ) ):
if ( question ):
tmp_slides += [ [ "", "", "" ] ]
clue = answer = False
tmp_slides[ -1 ][ 0 ] = entry
# clue
elif ( clue_format and re.search( clue_format, os.path.basename( entry ), re.IGNORECASE ) ):
if ( clue ):
tmp_slides += [ [ "", "", "" ] ]
question = answer = False
tmp_slides[ -1 ][ 1 ] = entry
# answer
elif ( answer_format and re.search( answer_format, os.path.basename( entry ), re.IGNORECASE ) ):
if ( answer ):
tmp_slides += [ [ "", "", "" ] ]
question = clue = False
tmp_slides[ -1 ][ 2 ] = entry
# add the file as a question TODO: maybe check for valid picture format?
elif ( entry and os.path.splitext( entry )[ 1 ].lower() in xbmc.getSupportedMedia( "picture" ) ):
tmp_slides += [ [ "", "", entry ] ]
# if there are folders call again (we want recursive)
if ( folders ):
tmp_slides.extend( _get_slides( folders, movie_mpaa ) )
return tmp_slides
示例15: showRarVideos
def showRarVideos( url ):
VIDEO_EXTENTIONS = xbmc.getSupportedMedia('video').split('|')
# remove some archive extensions
VIDEO_EXTENTIONS.remove(".rar")
VIDEO_EXTENTIONS.remove(".001")
VIDEO_EXTENTIONS.remove(".url")
found_video_file = False
dp = xbmcgui.DialogProgress()
dp.create("Finding video files in rar. Be Patient!")
def info_callback(raritem):
try:
currently_reading_rar_volume_file = raritem.volume_file.split('/')[-1]
completed = (raritem.volume+1 * 100) / 15
dp.update(completed, 'Reading rar data for the following rar file...', currently_reading_rar_volume_file, 'VOLUME #%s' % raritem.volume)
doLog("%s\n%s\n%s" % (raritem.file_offset, raritem.volume_file.split('/')[-1], raritem.type))
except:
pass
rar_file = rarfile.RarFile( url, crc_check=False, info_callback=info_callback )
if rar_file.needs_password():
errorNotice = 'XBMC.Notification("RAR IS PASSWORD PROTECTED!","Cannot handle a password protected archive.", 5000)'
xbmc.executebuiltin( errorNotice )
dp.close()
return False
for filename in rar_file.namelist():
file_info = rar_file.getinfo(filename)
doLog( "\tRAR INFO needs_password: %s - volume: %s - volume_file: %s - compress_type: %s" % (file_info.needs_password(), file_info.volume, file_info.volume_file, file_info.compress_type))
filename = filename.replace('\\','/')
dp.update(0, filename)
doLog( "FILENAME FOUND: %s" % filename )
# test for an extension otherwise skip
try:
file_ext_lower = "." + filename.lower().split('.')[-1]
doLog( "Checking Extension: %s" % file_ext_lower )
if file_ext_lower in (".rar",".001"):
errorNotice = 'XBMC.Notification("Archive within archive detected!","Cannot handle double packed archives.", 2000)'
xbmc.executebuiltin( errorNotice )
if file_ext_lower in VIDEO_EXTENTIONS:
# use the rar volume_file which holds the actual url to where this video file starts in the set.
# otherwise videos further in the set won't play. SWEET!
video_url = urllib.quote( file_info.volume_file ).replace("-", "%2d").replace(".", "%2e").replace("/", "%2f")
video_url = "rar://" + video_url + "/" + filename
found_video_file = True
doLog( "addLink( name=%s, url=%s)" % (filename, video_url))
addLink( name=filename, url=video_url)
except:
pass
dp.close()
return found_video_file