本文整理汇总了Python中xbmc.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildSubDir
def buildSubDir(url, doc):
xbmc.log('buildSubDir')
soup = BeautifulSoup(''.join(doc))
nav = soup.find('ul', attrs={'class': 'contentnav'})
if(not nav):
#no subdir (home page or flat category)
buildVideoDir(url, doc)
return
div = nav.find('div')
if(not div):
#no subdir (home page or flat category)
buildVideoDir(url, doc)
return
ul = div.find('ul')
for ulitem in ul.contents:
if(type(ulitem) == Tag):
if(ulitem.name == 'li'):
a = ulitem.find('a')
if(not a):
xbmc.log(missingelementtext%'a')
continue
url = BASE_URL + a['href']
addDir(a.text, url, 3, '')
示例2: play_picture_slideshow
def play_picture_slideshow(origurl, name):
print "Starting play_picture_slideshow(): " + str(origurl)
#user clicked on a picture
if origurl[-4:].lower()=='.jpg' or origurl[-4:].lower()=='.gif' or origurl[-4:].lower()=='.png':
print "Single picture mode"
origurl = origurl.replace( ' ', '%20' )
xbmc.log("adding to picture slideshow: " + str(origurl))
xbmc.executehttpapi("ClearSlideshow")
xbmc.executehttpapi("AddToSlideshow(%s)" % origurl)
xbmc.executebuiltin( "SlideShow(,,notrandom)" )
return
#user clicked on <start slideshow>
items = getItemsFromUrl(origurl)
xbmc.executehttpapi("ClearSlideshow")
itemCount=0
for item in items:
itemCount=itemCount+1
label, url, description, pubDate, guid, thumb, duration, rating, viewcount = getItemFields(item)
if url is not None and url != '':
xbmc.executehttpapi("AddToSlideshow(%s)" % url)
print "# of pictures added to sideshow " + str(itemCount)
xbmc.executebuiltin( "SlideShow(,,notrandom)" )
示例3: autostart
def autostart():
xbmc.log('script.pseudotv.live-Service: autostart')
xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("AutoStart PseudoTV Live","Service Starting...", 4000, THUMB) )
AUTOSTART_TIMER = [0,5,10,15,20]#in seconds
IDLE_TIME = AUTOSTART_TIMER[int(REAL_SETTINGS.getSetting('timer_amount'))]
sleep(IDLE_TIME)
xbmc.executebuiltin('RunScript("' + ADDON_PATH + '/default.py' + '")')
示例4: find_stream
def find_stream(url, name):
xbmc.log("Starting find_stream with url: " + str(url))
try:
pageUrl = url.split("&streamer=")[0]
streamer = url.split("&streamer=")[1]
print ('Opening ' + pageUrl)
res = open_url(pageUrl)
#print (res)
playpath = ''
swfUrl = ''
for line in res.split("\n"):
#print ("line:" + line)
matches = re.search(r'file.*\'(.+)\'', line)
if matches:
playpath = matches.group(1)
print ("Found playpath:" + playpath)
matches = re.search(r'(http.+\.swf)', line)
if matches:
swfUrl = matches.group(1)
print ("Found swfUrl:" + swfUrl)
streamurl = "%s playpath=%s swfUrl=%s pageurl=%s swfVfy=true live=true" % (streamer, playpath, swfUrl, pageUrl)
xbmc.log ("streamurl: " + streamurl)
return (streamurl)
except:
return (" ")
示例5: get_subscriptions
def get_subscriptions():
try:
content = read_from_file(SUBSCRIPTION_FILE)
lines = content.split('\n')
for line in lines:
data = line.split('\t')
if len(data) == 2:
if data[1].startswith('tt'):
tv_show_name = data[0]
tv_show_imdb = data[1]
tv_show_mode = "strm tv show dialog"
create_tv_show_strm_files(tv_show_name, tv_show_imdb, tv_show_mode, TV_SHOWS_PATH)
else:
mode = data[1]
items = get_menu_items(name, mode, "", "")
for (url, li, isFolder) in items:
paramstring = url.replace(sys.argv[0], '')
params = get_params(paramstring)
movie_name = urllib.unquote_plus(params["name"])
movie_data = urllib.unquote_plus(params["name"])
movie_imdb = urllib.unquote_plus(params["imdb_id"])
movie_mode = "strm movie dialog"
create_strm_file(movie_name, movie_data, movie_imdb, movie_mode, MOVIES_PATH)
except:
xbmc.log("[What the Furk] Failed to fetch subscription")
示例6: setup_sources
def setup_sources():
xbmc.log("[What the Furk] Trying to add source paths...")
source_path = os.path.join(xbmc.translatePath('special://profile/'), 'sources.xml')
try:
f = open(source_path, 'r')
content = f.read()
f.close()
r = re.search("(?i)(<sources>[\S\s]+?<video>[\S\s]+?>)\s+?(</video>[\S\s]+?</sources>)", content)
new_content = r.group(1)
if not check_sources_xml(MOVIES_PATH):
new_content += '<source><name>Movies (What the Furk)</name><path pathversion="1">'
new_content += MOVIES_PATH
new_content += '</path></source>'
if not check_sources_xml(TV_SHOWS_PATH):
new_content += '<source><name>TV Shows (What the Furk)</name><path pathversion="1">'
new_content += TV_SHOWS_PATH
new_content += '</path></source>'
new_content += r.group(2)
f = open(source_path, 'w')
f.write(new_content)
f.close()
dialog = xbmcgui.Dialog()
dialog.ok("Source folders added", "To complete the setup:", " 1) Restart XBMC.", " 2) Set the content type of added sources.")
#if dialog.yesno("Restart now?", "Do you want to restart XBMC now?"):
#xbmc.restart()
except:
xbmc.log("[What the Furk] Could not edit sources.xml")
示例7: authorize
def authorize(resource):
if is_authorized(resource):
xbmc.log(TAG + 'already authorized', xbmc.LOGDEBUG)
return
params = urllib.urlencode({'requestor': 'ESPN',
'deviceId': get_device_id(),
'resource': resource})
path = '/authorize'
url = urlparse.urlunsplit(['https', 'api.auth.adobe.com',
'api/v1' + path,
params, ''])
message = generate_message('GET', path)
resp = get_url_response(url, message)
settings = load_settings()
if 'authorize' not in settings:
settings['authorize'] = dict()
xbmc.log(TAG + 'resource %s' % resource, xbmc.LOGDEBUG)
if 'status' in resp and resp['status'] == 403:
raise AuthorizationException()
settings['authorize'][resource.decode('iso-8859-1').encode('utf-8')] = resp
save_settings(settings)
示例8: write_doc
def write_doc(self, filepath, doc):
with open(filepath, 'wb') as out:
try:
out.write(doc)
except:
xbmc.log('plugin.program.pneumatic failed to create .nfo file: %s' % \
xbmc.translatePath(filepath))
示例9: getEpisodeByAirdate_NEW
def getEpisodeByAirdate_NEW(self, tvdbid, airdate):
xbmc.log("getEpisodeByAirdate Creating Cache")
try:
response = urllib2.urlopen(self._buildUrl('GetEpisodeByAirDate.php', {'apikey' : self.apikey, 'seriesid' : tvdbid, 'airdate' : airdate})).read()
return response
except Exception,e:
return ''
示例10: getEpisodeByID_NEW
def getEpisodeByID_NEW(self, tvdbid):
xbmc.log("getEpisodeByID_NEW Creating Cache")
try:
response = urllib2.urlopen(self._buildUrl(self.apikey + '/series/' + tvdbid + '/all/en.xml')).read()
return response
except Exception,e:
return ''
示例11: _get_song_selection
def _get_song_selection(self, songs, title, swap, autoselect, songlist):
""" Returns a user selected song's url from a list of supplied songs """
# sort songs, removing duplicates
titles, dupes = self._sort_songs(songs, swap)
# if autoselect, try to find a match
if (autoselect):
# set key
if (len(songs[0]) == 3):
# we use an artist alias if one was entered
key = " - ".join([self.m_song.title, self.new_alias.get(self.m_song.artist, self.artist_aliases.get(self.m_song.artist, self.m_song.artist))]).lower()
else:
key = self.m_song.title.lower()
# loop thru and find a match FIXME: titles is sorted, so may not return best result?
choice = [count for count, k in enumerate(titles) if (k.lower() == key)]
# if we have a match return it
if (choice):
return dupes[titles[choice[0]]]
# if we are prefetching or autoselecting when not songlist skip selection, we only go this far for autoselect scrapers
if (self.prefetch or (autoselect and not songlist)):
return None
# set the time to auto close in msec, 80% of time remaining is plenty of time and gives prefetch some time
autoclose = int((xbmc.Player().getTotalTime() - xbmc.Player().getTime()) * 1000 * 0.80)
# get user selection
choice = xbmcgui.Dialog().select(u"{title} ({new})".format(title=self.m_song.title, new=title), titles, autoclose)
# return selection
if (choice >= 0):
return dupes[titles[choice]]
# log message only if no selection
xbmc.log(" Scraper::_get_song_selection (message='No selection made')", xbmc.LOGDEBUG)
# no selection return None
return None
示例12: _fetch_song_list
def _fetch_song_list(self, artist, scraper=0, usetitle=False):
try:
# log message
xbmc.log(u" {count}. Scraper::_fetch_song_list (scraper={scraper!r}, autoselect={auto!r})".format(count=scraper + 1, scraper=self.SCRAPERS[scraper]["title"], auto=self.SCRAPERS[scraper]["source"]["songlist"]["autoselect"]), xbmc.LOGDEBUG)
# do we want to include title
title = ["", self.m_song.title][usetitle]
# format url based on scraper
url = self._format_url(artist, title, scraper)
# fetch source
source = self._fetch_source(url, self.SCRAPERS[scraper]["url"]["useragent"]["string"], self.SCRAPERS[scraper]["source"]["encoding"], self.SCRAPERS[scraper]["source"]["compress"])
# scrape song list
songs = self.SCRAPERS[scraper]["source"]["songlist"]["regex"].findall(source)
# raise an error if no songs found
if (not len(songs)): raise
# get user selection
url = self._get_song_selection(songs, self.SCRAPERS[scraper]["title"], self.SCRAPERS[scraper]["source"]["songlist"]["format"], self.SCRAPERS[scraper]["source"]["songlist"]["autoselect"], not usetitle)
# add scraper to our skip alias list FIXME: we need a place that doesn't affect songlist always scrapers
if (not usetitle):
self.skip_alias += [scraper]
# if selection, format url
if (url is not None):
url = u"{address}{head}{url}".format(address=self.SCRAPERS[scraper]["url"]["address"], head=self.SCRAPERS[scraper]["url"]["song"]["title"]["head"], url=url)
# an error occurred, should only happen if artist was not found
except Exception as error:
# no artist found
return None, str(error)
else:
# success
return url, ""
示例13: _get_current_volume
def _get_current_volume( self ):
# get the current volume
result = xbmc.executeJSONRPC( volume_query )
match = re.search( '"volume" ?: ?([0-9]{1,3})', result )
volume = int(match.group(1))
xbmc.log( "[script.cinema.experience] - Current Volume: %d" % volume, level=xbmc.LOGDEBUG)
return volume
示例14: panDir
def panDir():
while not panAuth():
if xbmcgui.Dialog().yesno(_name, ' Login Failed', 'Bad User / Pass / Proxy', ' Check Settings?'):
_settings.openSettings()
else: exit()
sort = _settings.getSetting('sort')
stations = _pandora.stations
quickmix = stations.pop(0) # Quickmix
if sort == '0': stations = stations # Normal
elif sort == '2': stations = stations[::-1] # Reverse
else: stations = sorted(stations, key=lambda s: s.name) # A-Z
stations.insert(0, quickmix) # Quickmix back on top
for station in stations:
li = xbmcgui.ListItem(station.name, station.id)
li.setProperty('IsPlayable', 'true')
img = _settings.getSetting("img-%s" % station.id)
li.setIconImage(img)
li.setThumbnailImage(img)
li.addContextMenuItems([('Select Thumb', "RunPlugin(plugin://%s/?thumb=%s)" % (_plugin, station.id))])
xbmcplugin.addDirectoryItem(_handle, "%s?station=%s" % (_base, station.id), li)
xbmcplugin.endOfDirectory(_handle, cacheToDisc = False)
xbmc.log("%s.Dir OK" % _plugin, xbmc.LOGDEBUG)
示例15: GetHttpData
def GetHttpData(url):
print "getHttpData: " + url
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)')
try:
response = urllib2.urlopen(req)
httpdata = response.read()
if response.headers.get('content-encoding', None) == 'gzip':
httpdata = gzip.GzipFile(fileobj=StringIO.StringIO(httpdata)).read()
charset = response.headers.getparam('charset')
response.close()
except:
xbmc.log( "%s: %s (%d) [%s]" % (
__addonname__,
sys.exc_info()[ 2 ].tb_frame.f_code.co_name,
sys.exc_info()[ 2 ].tb_lineno,
sys.exc_info()[ 1 ]
), level=xbmc.LOGERROR)
return ''
match = re.compile('<meta http-equiv=["]?[Cc]ontent-[Tt]ype["]? content="text/html;[\s]?charset=(.+?)"').findall(httpdata)
if len(match)>0:
charset = match[0]
if charset:
charset = charset.lower()
if (charset != 'utf-8') and (charset != 'utf8'):
httpdata = httpdata.decode(charset, 'ignore').encode('utf8', 'ignore')
return httpdata