本文整理汇总了Python中DownloadUtils.DownloadUtils.get方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadUtils.get方法的具体用法?Python DownloadUtils.get怎么用?Python DownloadUtils.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DownloadUtils.DownloadUtils
的用法示例。
在下文中一共展示了DownloadUtils.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onNotification
# 需要导入模块: from DownloadUtils import DownloadUtils [as 别名]
# 或者: from DownloadUtils.DownloadUtils import get [as 别名]
def onNotification (self,sender,method,data):
WINDOW = self.WINDOW
downloadUtils = DownloadUtils()
#player started playing an item -
if ("Playlist.OnAdd" in method or "Player.OnPlay" in method) and utils.settings('useDirectPaths')=='true':
jsondata = json.loads(data)
if jsondata != None:
if jsondata.has_key("item"):
if jsondata.get("item").has_key("id") and jsondata.get("item").has_key("type"):
id = jsondata.get("item").get("id")
type = jsondata.get("item").get("type")
embyid = ReadKodiDB().getEmbyIdByKodiId(id,type)
if embyid != None:
WINDOW = xbmcgui.Window( 10000 )
username = WINDOW.getProperty('currUser')
userid = WINDOW.getProperty('userId%s' % username)
server = WINDOW.getProperty('server%s' % username)
url = "{server}/mediabrowser/Users/{UserId}/Items/" + embyid + "?format=json&ImageTypeLimit=1"
result = downloadUtils.downloadUrl(url)
print "Here: %s" % result
userData = result['UserData']
playurl = PlayUtils().getPlayUrl(server, embyid, result)
watchedurl = 'http://' + server + '/mediabrowser/Users/'+ userid + '/PlayedItems/' + embyid
positionurl = 'http://' + server + '/mediabrowser/Users/'+ userid + '/PlayingItems/' + embyid
deleteurl = 'http://' + server + '/mediabrowser/Items/' + embyid
# set the current playing info
WINDOW.setProperty(playurl+"watchedurl", watchedurl)
WINDOW.setProperty(playurl+"positionurl", positionurl)
WINDOW.setProperty(playurl+"deleteurl", "")
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
if result.get("Type")=="Episode":
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
else:
WINDOW.setProperty(playurl+"refresh_id", embyid)
WINDOW.setProperty(playurl+"runtimeticks", str(result.get("RunTimeTicks")))
WINDOW.setProperty(playurl+"type", result.get("Type"))
WINDOW.setProperty(playurl+"item_id", embyid)
if PlayUtils().isDirectPlay(result) == True:
playMethod = "DirectPlay"
else:
playMethod = "Transcode"
WINDOW.setProperty(playurl+"playmethod", playMethod)
mediaSources = result.get("MediaSources")
if(mediaSources != None):
mediaStream = mediaSources[0].get('MediaStreams')
defaultsubs = ""
for stream in mediaStream:
if u'Subtitle' in stream[u'Type'] and stream[u'IsDefault']:
if u'Language' in stream:
defaultsubs = stream[u'Language']
else:
defaultsubs = stream[u'Codec']
WINDOW.setProperty("%ssubs" % playurl, defaultsubs.encode('utf-8'))
if mediaSources[0].get('DefaultAudioStreamIndex') != None:
WINDOW.setProperty(playurl+"AudioStreamIndex", str(mediaSources[0].get('DefaultAudioStreamIndex')))
if mediaSources[0].get('DefaultSubtitleStreamIndex') != None:
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0].get('DefaultSubtitleStreamIndex')))
if method == "VideoLibrary.OnUpdate":
jsondata = json.loads(data)
if jsondata != None:
playcount = None
playcount = jsondata.get("playcount")
item = jsondata.get("item").get("id")
type = jsondata.get("item").get("type")
prop = WINDOW.getProperty('Played%s%s' % (type,item))
processWatched = WINDOW.getProperty('played_skipWatched')
if (playcount != None) and (prop != "true") and (processWatched != "true"):
WINDOW.setProperty("Played%s%s" % (type,item), "true")
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
self.clearProperty(type,item)
if method == "System.OnWake":
xbmc.sleep(10000) #Allow network to wake up
WINDOW.setProperty("OnWakeSync", "true")
if method == "VideoLibrary.OnRemove":
xbmc.log('Intercepted remove from sender: ' + sender + ' method: ' + method + ' data: ' + data)
jsondata = json.loads(data)
id = ReadKodiDB().getEmbyIdByKodiId(jsondata.get("id"), jsondata.get("type"))
if id == None:
return
xbmc.log("Deleting Emby ID: " + id + " from database")
connection = utils.KodiSQL()
cursor = connection.cursor()
#.........这里部分代码省略.........
示例2: onNotification
# 需要导入模块: from DownloadUtils import DownloadUtils [as 别名]
# 或者: from DownloadUtils.DownloadUtils import get [as 别名]
def onNotification (self, sender, method, data):
WINDOW = self.WINDOW
downloadUtils = DownloadUtils()
#player started playing an item -
if ("Playlist.OnAdd" in method or "Player.OnPlay" in method):
jsondata = json.loads(data)
if jsondata:
if jsondata.has_key("item"):
if jsondata.get("item").has_key("id") and jsondata.get("item").has_key("type"):
id = jsondata.get("item").get("id")
type = jsondata.get("item").get("type")
if (utils.settings('useDirectPaths')=='true' and not type == "song") or (type == "song" and utils.settings('enableMusicSync') == "true"):
if type == "song":
connection = utils.KodiSQL('music')
cursor = connection.cursor()
embyid = ReadKodiDB().getEmbyIdByKodiId(id, type, connection, cursor)
cursor.close()
else:
embyid = ReadKodiDB().getEmbyIdByKodiId(id,type)
if embyid:
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json" % embyid
result = downloadUtils.downloadUrl(url)
self.logMsg("Result: %s" % result, 2)
playurl = None
count = 0
while not playurl and count < 2:
try:
playurl = xbmc.Player().getPlayingFile()
except RuntimeError:
xbmc.sleep(200)
else:
listItem = xbmcgui.ListItem()
PlaybackUtils().setProperties(playurl, result, listItem)
if type == "song" and utils.settings('directstreammusic') == "true":
utils.window('%splaymethod' % playurl, value="DirectStream")
else:
utils.window('%splaymethod' % playurl, value="DirectPlay")
count += 1
if method == "VideoLibrary.OnUpdate":
# Triggers 4 times, the following is only for manually marking as watched/unwatched
jsondata = json.loads(data)
try:
playcount = jsondata.get('playcount')
item = jsondata['item']['id']
type = jsondata['item']['type']
prop = utils.window('Played%s%s' % (type, item))
except:
self.logMsg("Could not process VideoLibrary.OnUpdate data.", 1)
else:
self.logMsg("VideoLibrary.OnUpdate: %s" % data, 2)
if prop != "true":
# Set property to prevent the multi triggering
utils.window('Played%s%s' % (type, item), "true")
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
self.clearProperty(type, item)
if method == "System.OnWake":
xbmc.sleep(10000) #Allow network to wake up
WINDOW.setProperty("OnWakeSync", "true")
if method == "VideoLibrary.OnRemove":
xbmc.log('Intercepted remove from sender: ' + sender + ' method: ' + method + ' data: ' + data)
jsondata = json.loads(data)
id = ReadKodiDB().getEmbyIdByKodiId(jsondata.get("id"), jsondata.get("type"))
if id == None:
return
xbmc.log("Deleting Emby ID: " + id + " from database")
connection = utils.KodiSQL()
cursor = connection.cursor()
cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))
connection.commit()
cursor.close
if jsondata:
if jsondata.get("type") == "episode" or "movie":
url='{server}/mediabrowser/Items?Ids=' + id + '&format=json'
#This is a check to see if the item exists on the server, if it doesn't it may have already been deleted by another client
result = DownloadUtils().downloadUrl(url)
item = result.get("Items")[0]
if data:
return_value = xbmcgui.Dialog().yesno("Confirm Delete", "Delete file on Emby Server?")
if return_value:
url='{server}/mediabrowser/Items/' + id
xbmc.log('Deleting via URL: ' + url)
DownloadUtils().downloadUrl(url, type="DELETE")
elif method == "Playlist.OnClear":
self.logMsg("Clear playback properties.", 2)
#.........这里部分代码省略.........
示例3: BrowseChannels
# 需要导入模块: from DownloadUtils import DownloadUtils [as 别名]
# 或者: from DownloadUtils.DownloadUtils import get [as 别名]
def BrowseChannels(id, folderid=None):
_addon_id = int(sys.argv[1])
_addon_url = sys.argv[0]
xbmcplugin.setContent(int(sys.argv[1]), 'files')
if folderid:
url = "{server}/mediabrowser/Channels/" + id + "/Items?userid={UserId}&folderid=" + folderid + "&format=json"
else:
if id == "0": # id 0 is the root channels folder
url = "{server}/mediabrowser/Channels?{UserId}&format=json"
else:
url = "{server}/mediabrowser/Channels/" + id + "/Items?userid={UserId}&format=json"
results = DownloadUtils().downloadUrl(url)
if results:
result = results.get("Items")
if(result == None):
result = []
item_count = len(result)
current_item = 1;
for item in result:
id=str(item.get("Id")).encode('utf-8')
type=item.get("Type").encode('utf-8')
if(item.get("Name") != None):
tempTitle = item.get("Name")
tempTitle=tempTitle.encode('utf-8')
else:
tempTitle = "Missing Title"
if type=="ChannelFolderItem":
isFolder = True
else:
isFolder = False
item_type = str(type).encode('utf-8')
if(item.get("ChannelId") != None):
channelId = str(item.get("ChannelId")).encode('utf-8')
channelName = ''
if(item.get("ChannelName") != None):
channelName = item.get("ChannelName").encode('utf-8')
if(item.get("PremiereDate") != None):
premieredatelist = (item.get("PremiereDate")).split("T")
premieredate = premieredatelist[0]
else:
premieredate = ""
#mediaStreams=API().getMediaStreams(item, True)
#people = API().getPeople(item)
# Process Genres
genre = API().getGenre(item)
# Process UserData
userData = item.get("UserData")
PlaybackPositionTicks = '100'
overlay = "0"
favorite = "False"
seekTime = 0
if(userData != None):
if userData.get("Played") != True:
overlay = "7"
watched = "true"
else:
overlay = "6"
watched = "false"
if userData.get("IsFavorite") == True:
overlay = "5"
favorite = "True"
else:
favorite = "False"
if userData.get("PlaybackPositionTicks") != None:
PlaybackPositionTicks = str(userData.get("PlaybackPositionTicks"))
reasonableTicks = int(userData.get("PlaybackPositionTicks")) / 1000
seekTime = reasonableTicks / 10000
playCount = 0
if(userData != None and userData.get("Played") == True):
playCount = 1
# Populate the details list
details={'title' : tempTitle,
'channelname' : channelName,
'plot' : item.get("Overview"),
'Overlay' : overlay,
'playcount' : str(playCount)}
if item.get("Type") == "ChannelVideoItem":
xbmcplugin.setContent(_addon_id, 'movies')
elif item.get("Type") == "ChannelAudioItem":
xbmcplugin.setContent(_addon_id, 'songs')
# Populate the extraData list
extraData={'thumb' : API().getArtwork(item, "Primary") ,
#.........这里部分代码省略.........