Esempio n. 1
0
def view(url, page):
	if page==1:
		li = xbmcgui.ListItem("Random")	
		url_next=build_url({"command":"view_random", "tumblrURL":url})
		xbmcplugin.addDirectoryItem(handle=addon_handle, url=url_next, listitem=li, isFolder=True)
	r = requests.get(url+'/page/'+str(page))
	html = r.text		
	soup = BeautifulSoup(html)		
	imgs=soup.findAll('img')
	urls=[]
	for img in imgs:
		img_src=img.get('src')
		if img_src.find('media.tumblr.com')>=0:
			if img_src.find('media.tumblr.com/avatar')==-1:
				urls.append(img_src)					
				
	#temp_path=xbmc.translatePath(addon.getAddonInfo('profile'))
	
	CMD.addDirectoryItem_Images(addon_handle, urls, xbmc.translatePath(addon.getAddonInfo('profile')))	
	
	li = xbmcgui.ListItem("Next(%s)" % str(page+1))	
	url_next=build_url({"command":"view", "tumblrURL":url, "page":str(page+1)})
	xbmcplugin.addDirectoryItem(handle=addon_handle, url=url_next, listitem=li, isFolder=True)
	
	li = xbmcgui.ListItem("Next(%s)" % str(page+9))	
	url_next=build_url({"command":"view", "tumblrURL":url, "page":str(page+9)})
	xbmcplugin.addDirectoryItem(handle=addon_handle, url=url_next, listitem=li, isFolder=True)
Esempio n. 2
0
def view_random(url):
	urls=[]
	for i in range(1,20):	
		r = requests.get(url+'/random')
		html = r.text		
		soup = BeautifulSoup(html)		
		imgs=soup.findAll('img')			
		for img in imgs:
			img_src=img.get('src')
			if img_src.find('media.tumblr.com')>=0:
				if img_src.find('media.tumblr.com/avatar')==-1:
					urls.append(img_src)
	CMD.addDirectoryItem_Images(addon_handle, urls, xbmc.translatePath(addon.getAddonInfo('profile')))
	xbmc.log(str(urls))
	li = xbmcgui.ListItem("Random")	
	url_next=build_url({"command":"view_random", "tumblrURL":url})
	xbmcplugin.addDirectoryItem(handle=addon_handle, url=url_next, listitem=li, isFolder=True)
Esempio n. 3
0
def view_list_tumblr():
	xbmc.log(xbmcaddon.Addon().getSetting("tumblrIDs"))
	tumblrIDs=xbmcaddon.Addon().getSetting("tumblrIDs").split(";")
	xbmc.log(str(tumblrIDs))
	for id in tumblrIDs:
		if (id!=""):
			li = xbmcgui.ListItem(id)	
			li.setIconImage('https://api.tumblr.com/v2/blog/%s.tumblr.com/avatar' % id)
			url=build_url({"command":"view", "tumblrURL":'http://'+id+".tumblr.com", "page":"1"})
			li.addContextMenuItems([
				('Remove', 'XBMC.RunPlugin(%s)' % CMD.build_url(base_url,{'command':'remove','id':id}),)])
			xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
			
	li = xbmcgui.ListItem("Add")	
	url=build_url({"command":"addTumblrID","addon_handle":str(addon_handle)})
	xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
	xbmcplugin.endOfDirectory(addon_handle)