Kodi Community Forum
Solved Suddenly Failed to open stream - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Solved Suddenly Failed to open stream (/showthread.php?tid=246644)



Suddenly Failed to open stream - zchira - 2015-11-06

I am wokring on some plugin that show the live stream of some regional tv station.
Plugin worked more then a month, and today I noticed that kodi fails opening that stream.

Here is some log dana:

Code:
22:33:31 T:140596006082304  NOTICE: Thread LanguageInvoker start, auto delete: false
22:33:31 T:140596006082304  NOTICE: -->Python Interpreter Initialized<--
22:33:31 T:140597123848256   ERROR: Control 51 in window 10025 has been asked to focus, but it can't
22:33:31 T:140596006082304  NOTICE: >>>>>plugin://plugin.video.n1exyu/?
22:33:31 T:140596022867712  NOTICE: Thread BackgroundLoader start, auto delete: false
22:33:36 T:140597123848256  NOTICE: DVDPlayer: Opening: http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1srb&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0
22:33:36 T:140597123848256 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
22:33:36 T:140596006082304  NOTICE: Thread DVDPlayer start, auto delete: false
22:33:36 T:140596006082304  NOTICE: Creating InputStream
22:33:37 T:140596006082304   ERROR: CCurlFile::FillBuffer - Failed: HTTP returned error 403
22:33:37 T:140596006082304   ERROR: CCurlFile::Open failed with code 403 for http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1srb&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0
22:33:37 T:140596006082304   ERROR: Open - failed to open source <http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1srb&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0>
22:33:37 T:140596006082304  NOTICE: Creating Demuxer
22:33:37 T:140596006082304   ERROR: OpenDemuxStream - Error creating demuxer
22:33:37 T:140596006082304  NOTICE: CDVDPlayer::OnExit()
22:33:37 T:140597123848256   ERROR: Playlist Player: skipping unplayable item: 0, path [http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1srb&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0]
22:33:37 T:140596006082304  NOTICE: Thread BackgroundLoader start, auto delete: false

As you can se the stream link is:
http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1srb&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0

when I open that link in firefox it offers me to open it in VLC and that workd (vlc opens the stream). If I choose to save file it saves the file with content:

Code:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1496000,PROGRAM-ID=1
http://185.20.36.172:8080/stream?i=4336644558877663&k=fb747ea095c96e435163d40bff61c876a670431429b318828fefcae007c6fcf20c73d3e4c34faee7131f941d2264865f00a08c5fd6b18f23b906a709d9249cb5a164959f2295180507c2dbec85152f3a0e7121752fa6aa0dd6266b854147e8efe4c22560d4ba5d411e75eab1845f99bf41877bdb994579a0609c3f34f0a548bc0aa74805e2c79b094a9b876ed0332ac1e031d7f379a73a6e230aab4cfbe60b614cb34d5467beef386041c3f8ab941c6e8c908cc8b82ae2e8c700426f3956f7c49d93779d37b66990&sp=n1info&u=n1info&player=m3u8
#EXT-X-STREAM-INF:BANDWIDTH=286000,PROGRAM-ID=1
http://185.20.36.172:8080/variantplaylist/?session=52c6b17979fc70dd524dd47347cd23ee&stream=200kb&player=m3u8
#EXT-X-STREAM-INF:BANDWIDTH=596000,PROGRAM-ID=1
http://185.20.36.172:8080/variantplaylist/?session=52c6b17979fc70dd524dd47347cd23ee&stream=500kb&player=m3u8
#EXT-X-STREAM-INF:BANDWIDTH=64000,PROGRAM-ID=1
http://185.20.36.172:8080/variantplaylist/?session=52c6b17979fc70dd524dd47347cd23ee&stream=64kb&player=m3u8

I am not sure what is the problem? I guess that something is changed on their server but not sure what. The error ocurres on my both systems (kodi on raspberry pi2, and on arch linux).
Any idea or direction?


RE: Suddenly Failed to open stream - ronie - 2015-11-06

you're getting a permission denied.
perhaps they started checking the user-agent in the http request.


RE: Suddenly Failed to open stream - zchira - 2015-11-07

Is it possible to do some workaround (to manually set the user-agent from the code or somethin like that)?


RE: Suddenly Failed to open stream - ronie - 2015-11-07

Code:
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')



RE: Suddenly Failed to open stream - zchira - 2015-11-07

Thanks for your answer

Sorry for possibly stupid question (I am tottaly new to kodi/python dev), but where those line should be added?

Here is the part of the code where I am creating the list items:
Code:
def INDEX():
    url = 'http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1srb&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0'
    li = xbmcgui.ListItem('N1 Live [Serbia]', iconImage=iconImage)
    li.setProperty('isplayable', 'true')
    li.setProperty('fanart_image', fanart)
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

    url = 'http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1hr&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0'
    li = xbmcgui.ListItem('N1 Live [Croatia]', iconImage=iconImage)
    li.setProperty('isplayable', 'true')
    li.setProperty('fanart_image', fanart)
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

    url = 'http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1bih&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0'
    li = xbmcgui.ListItem('N1 Live [BiH]', iconImage=iconImage)
    li.setProperty('isplayable', 'true')
    li.setProperty('fanart_image', fanart)
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

    add_show_folder(PRESSING_SHOW)
    add_show_folder(DNEVNIK_19_SHOW)

    xbmcplugin.endOfDirectory(addon_handle)

Here is the whole addon.py file.


RE: Suddenly Failed to open stream - zchira - 2015-11-07

maybe I should try something like setResolvedUrl ?
http://forum.kodi.tv/showthread.php?tid=173986


RE: Suddenly Failed to open stream - ronie - 2015-11-07

ah, for plugin streams you can simply append the user-agent to the url:
Code:
HEADERS = urllib.urlencode({'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'})
url = 'http://best.str.n1info.com:8080/stream?sp=n1info&channel=n1srb&stream=1mb&b=6&player=m3u8&u=n1info&p=n1Sh4redSecre7iNf0|%s' % HEADERS



RE: Suddenly Failed to open stream - zchira - 2015-11-07

Great!
That worked!
Thank you, ronie