2014-07-20, 22:41
Scrape my script scrape correct video url from website but cannot pass variable to directory listing
Hi everyone, I am trying to make an simple video addon, based on different url (it changes once in a while), so i need to scrap webpage before i can pass exact url to xbmc.addDirectory
So far in PythonShell i am able to 'print videourl'
Manually pasting that url from python shell it shows in video addon and plays fine but i need to get it scraped but got ScriptFailed while passing variables as url in xbmc.AddDirectory
And i was following an video addon tutorial to make an directory listing:
If i would paste url manually it plays nicely without any problems, but question is how do You passing information between url and xbmc addDirectory?
but when i tried to put an variable videourl i have an ScriptFailed!
Hope any one do know an answer, or thoughts?
Thanks for looking anyways.
////////edit
I have found an issue in url there is an symbols that i need to delete and thats why it crashes question is how can i repair that?
debug.log
23:20:42 T:4612 WARNING: XFILE::CFileFactory::CreateLoader - Unsupported protocol(['http) in
and oryginal url is:
['http://anyexamples.com/myfile/?d=1402956534&play=362276699']
i have set videourl to str and tried with unicode and still without success.
Anyone knows how can i remove [' on beggining on url and '] at end of url?
...............................solved, to remove them characters i used:
1.changed url to string format, that was first issue
videourlstr = str(videoscrapedurl)
2.removed [' from string oryginal scraped url in first phase then
surl1 = videoscrapedurl.replace("['", "")
3. removed '] from second phase
surl2 = surl1.replace("']", "")
#print surldoma2
4. and passed surl2 into directory url =)
Hi everyone, I am trying to make an simple video addon, based on different url (it changes once in a while), so i need to scrap webpage before i can pass exact url to xbmc.addDirectory
So far in PythonShell i am able to 'print videourl'
Manually pasting that url from python shell it shows in video addon and plays fine but i need to get it scraped but got ScriptFailed while passing variables as url in xbmc.AddDirectory
And i was following an video addon tutorial to make an directory listing:
Quote:import urllib
import re
import xbmcgui
import xbmcplugin
#here i am parsing an url to get exact url
urls = ["justanfirstmainpageurl", "Thisurltobeparsed"]
regextokens = '<a href="(.+?)"><div class="btn_container">'
pattern = re.compile(regextokens)
len(urls)
htmlfile = urllib.urlopen(urls[1])
htmltext = htmlfile.read()
videourl = re.findall(pattern, htmltext)
#that is just for testing in PythonIDE and videourl is showing correct scraped url to be played in xbmc
#print videourl
addon_handle = int(sys.argv[1])
xbmcplugin.setContent(addon_handle, 'movies')
url = videourl #i have problem with this section
li = xbmcgui.ListItem('ParsedURLForVideo', iconImage='DefaultVideo.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
xbmcplugin.endOfDirectory(addon_handle)
If i would paste url manually it plays nicely without any problems, but question is how do You passing information between url and xbmc addDirectory?
but when i tried to put an variable videourl i have an ScriptFailed!
Hope any one do know an answer, or thoughts?
Thanks for looking anyways.
////////edit
I have found an issue in url there is an symbols that i need to delete and thats why it crashes question is how can i repair that?
debug.log
23:20:42 T:4612 WARNING: XFILE::CFileFactory::CreateLoader - Unsupported protocol(['http) in
and oryginal url is:
['http://anyexamples.com/myfile/?d=1402956534&play=362276699']
i have set videourl to str and tried with unicode and still without success.
Anyone knows how can i remove [' on beggining on url and '] at end of url?
...............................solved, to remove them characters i used:
1.changed url to string format, that was first issue
videourlstr = str(videoscrapedurl)
2.removed [' from string oryginal scraped url in first phase then
surl1 = videoscrapedurl.replace("['", "")
3. removed '] from second phase
surl2 = surl1.replace("']", "")
#print surldoma2
4. and passed surl2 into directory url =)