2019-03-11, 07:07
So I'm making an addon for catchup on the following sites.
flowerstv.in
mazhavilmanorama.com/videos/playlists/thateem-mutteem.html, as well as the other shows.
The problems I'm facing.
The first site, I'm able to scrape the site for videos e.t.c
I'm just having a problem for when the url is scraped, on how to play it. i tried using urlresolver, but I can't get it to work.
I'll paste the cod below.
For the second site, I'm able to scrape the site for all the info I need, except the link to play. This is because they use brightcove to play videos. If anyone knows how to decode the link please reply.
MY CODE FOR THE FIRST SiTE. I've tried using urlresolver, but i can't get it to resolve the url.
import xbmcaddon,os,requests,xbmc,xbmcgui,urllib,urllib2,re,xbmcplugin
from resources.lib.modules.channels import *
def CATEGORIES():
r = requests.get('http://www.flowerstv.in/category/uppum-mulakum/')
match = re.compile('data-original="(.+?)" alt="(.+?)" />.+?effect"><a href="(.+?)"',re.DOTALL).findall(r.content)
for image,name,url in match:
addDir3(name.replace('–','-'),'',3,image,'','')
def UPPU(url,name):
r = requests.get('url')
match = re.compile('Url" src="(.+?)".+?alt="(.+?)".+?<p><iframe src="(.+?)"',re.DOTALL).findall(r.content)
for image,name,url in match:
addDir3(name,'',3,image,'','')
#So here, the addon can scrape almost everything.
#The '' in addDir 3 is the url.
#How can I play that URL?
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
#################################################################################################################
# NEED BELOW CHANGED
def addDir(name,url,mode,iconimage):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def addDir2(name,url,mode,iconimage):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
return ok
###############################################################################################################
def addDir3(name,url,mode,iconimage,fanart,description):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&fanart="+urllib.quote_plus(fanart)+"&description="+urllib.quote_plus(description)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description } )
liz.setProperty( "Fanart_Image", fanart )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def setView(content, viewType):
# set content type so library shows more views and info
if content:
xbmcplugin.setContent(int(sys.argv[1]), content)
if ADDON.getSetting('auto-view')=='true':
xbmc.executebuiltin("Container.SetViewMode(%s)" % viewType )
params=get_params()
url=None
name=None
mode=None
iconimage=None
fanart=None
description=None
try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
iconimage=urllib.unquote_plus(params["iconimage"])
except:
pass
try:
mode=int(params["mode"])
except:
pass
try:
fanart=urllib.unquote_plus(params["fanart"])
except:
pass
try:
description=urllib.unquote_plus(params["description"])
except:
pass
print "Mode: "+str(mode)
print "URL: "+str(url)
print "Name: "+str(name)
if mode==None or url==None or len(url)<1:
print ""
CATEGORIES()
elif mode==1:
OPEN_URL(url)
elif mode==3:
UPPU(url,name)
xbmcplugin.endOfDirectory(int(sys.argv[1]))
flowerstv.in
mazhavilmanorama.com/videos/playlists/thateem-mutteem.html, as well as the other shows.
The problems I'm facing.
The first site, I'm able to scrape the site for videos e.t.c
I'm just having a problem for when the url is scraped, on how to play it. i tried using urlresolver, but I can't get it to work.
I'll paste the cod below.
For the second site, I'm able to scrape the site for all the info I need, except the link to play. This is because they use brightcove to play videos. If anyone knows how to decode the link please reply.
MY CODE FOR THE FIRST SiTE. I've tried using urlresolver, but i can't get it to resolve the url.
import xbmcaddon,os,requests,xbmc,xbmcgui,urllib,urllib2,re,xbmcplugin
from resources.lib.modules.channels import *
def CATEGORIES():
r = requests.get('http://www.flowerstv.in/category/uppum-mulakum/')
match = re.compile('data-original="(.+?)" alt="(.+?)" />.+?effect"><a href="(.+?)"',re.DOTALL).findall(r.content)
for image,name,url in match:
addDir3(name.replace('–','-'),'',3,image,'','')
def UPPU(url,name):
r = requests.get('url')
match = re.compile('Url" src="(.+?)".+?alt="(.+?)".+?<p><iframe src="(.+?)"',re.DOTALL).findall(r.content)
for image,name,url in match:
addDir3(name,'',3,image,'','')
#So here, the addon can scrape almost everything.
#The '' in addDir 3 is the url.
#How can I play that URL?
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
#################################################################################################################
# NEED BELOW CHANGED
def addDir(name,url,mode,iconimage):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def addDir2(name,url,mode,iconimage):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
return ok
###############################################################################################################
def addDir3(name,url,mode,iconimage,fanart,description):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&fanart="+urllib.quote_plus(fanart)+"&description="+urllib.quote_plus(description)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description } )
liz.setProperty( "Fanart_Image", fanart )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def setView(content, viewType):
# set content type so library shows more views and info
if content:
xbmcplugin.setContent(int(sys.argv[1]), content)
if ADDON.getSetting('auto-view')=='true':
xbmc.executebuiltin("Container.SetViewMode(%s)" % viewType )
params=get_params()
url=None
name=None
mode=None
iconimage=None
fanart=None
description=None
try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
iconimage=urllib.unquote_plus(params["iconimage"])
except:
pass
try:
mode=int(params["mode"])
except:
pass
try:
fanart=urllib.unquote_plus(params["fanart"])
except:
pass
try:
description=urllib.unquote_plus(params["description"])
except:
pass
print "Mode: "+str(mode)
print "URL: "+str(url)
print "Name: "+str(name)
if mode==None or url==None or len(url)<1:
print ""
CATEGORIES()
elif mode==1:
OPEN_URL(url)
elif mode==3:
UPPU(url,name)
xbmcplugin.endOfDirectory(int(sys.argv[1]))