예제 #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)
예제 #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)