Noob here. Trying to play mp4 from website
#1
Hi guys,
I'm trying to make a TV Commercial plugin.

Using the default tutorial, I've managed to successfully scrape and play an MP4, but there is only sound, and no video. I'm linking directly to the MP4.

I parsed this:
http://files.advertolog.com/@/Advertolog...3A10%7D%7D

To get this:
http://files.advertolog.com/files/adsarc...-87352.mp4

It plays fine in a browser, but in XBMC, only audio, and no video.

Here is my default.py:
import urllib,urllib2,re,xbmcplugin,xbmcgui

#TV Commercials - by LordIndy 2011.

def CATEGORIES():
addDir('Canada','http://www.advertolog.com/countries/canada%2Cmedia-adverts%2Cyear-2011/',1,'http://files.advertolog.com/@/Advertolog/Layouts/advertolog-logo.png')
# addDir( '','',1,'')

def INDEX(url):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
req.add_header('Content-type', 'octet-stream/flv')
response = urllib2.urlopen(req)
link=response.read()
response.close()
match=re.compile('<a href="(.+?)" class="col-media-photo" title=".+?">\n\t\t<img src="(.+?)" alt="(.+?)" />\n\t</a>').findall(link)
for url,thumbnail,name, in match:
addDir(name,'http://www.advertolog.com'+url,2,thumbnail)

def VIDEOLINKS(url,name):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
match=re.compile('meta property="og:video" content="(.+?)" />').findall(link)
match[0]=re.sub('%3A',':',match[0])
match[0]=re.sub('%2F','/',match[0])
match[0]=re.sub('http.*?clip%22:%7B%22url%22:%22','/',match[0])
match[0]=re.search('h.*?.mp4', match[0]).group()
for url in match:
addLink(name,match[0],'')



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




def addLink(name,url,iconimage):
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
liz.setProperty("IsPlayable","true")
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
return ok


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


params=get_params()
url=None
name=None
mode=None

try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
mode=int(params["mode"])
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:
print ""+url
INDEX(url)

elif mode==2:
print ""+url
VIDEOLINKS(url,name)



xbmcplugin.endOfDirectory(int(sys.argv[1]))
Reply
#2
I'm guessing it has something to do with the flowplayer...so I'll need to read up on streaming... thought I could smply point to the mp4 file.
Reply
#3
Nevermind...I got it working fine in Linux...must be a windows thing with XBMC and MP4's...renderer or whatnot
Reply

Logout Mark Read Team Forum Stats Members Help
Noob here. Trying to play mp4 from website0