Kodi Community Forum
Release [Module] youtube-dl - multi-site playable URL resolver - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Video Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=154)
---- Thread: Release [Module] youtube-dl - multi-site playable URL resolver (/showthread.php?tid=200877)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20


RE: [Module] youtube-dl - multi-site playable URL resolver - d0rax - 2016-05-31

Hello ruuk, very nice addon.

Just discovered youtube-dl and am using it to expand the supported videos on my addon.

This is the code I use:
Code:
def playYoutube_dlVideo(url, name, type):
    #url = "http://www.youtube.com/watch?v=_yVv9dx88x0"   #a youtube ID will work as well and of course you could pass the url of another site
    url='http://www.220.ro/funny/Cocalarus-Retardus/cEWvAHMxuc/'
    url='http://www.3sat.de/mediathek/?mode=play&obj=51264'
    url='http://www.4tube.com/videos/209271/hurry-fuck-i-bored'
    choices = []
    stream_url=""

    if YDStreamExtractor.mightHaveVideo(url,resolve_redirects=True):
        log('might have video=true ' + url)
        vid = YDStreamExtractor.getVideoInfo(url,quality=1,resolve_redirects=True)  #quality is 0=SD, 1=720p, 2=1080p and is a maximum
        
        if vid:
            log("vid is true")
            if vid.hasMultipleStreams():
                log("vid hasMultipleStreams")
                for s in vid.streams():
                    title = s['title']
                    log('choices' + title  )
                    choices.append(title)
                #index = some_function_asking_the_user_to_choose(choices)
                vid.selectStream(0) #You can also pass in the the dict for the chosen stream
    
            stream_url = vid.streamURL()                         #This is what Kodi (XBMC) will play        
            log("stream_url="+stream_url)
            listitem = xbmcgui.ListItem(path=stream_url)
            xbmcplugin.setResolvedUrl(pluginhandle, True, listitem)
        else:
            log("can't get getVideoInfo")

I get this error:
Code:
00:28:46 T:7180  NOTICE: script.module.youtube.dl: youtube_dl core version: 2016.05.21.2
00:28:46 T:7180   ERROR: C:\Users\dorpc\AppData\Roaming\Kodi\addons\script.module.youtube.dl\lib\YDStreamExtractor.py:441: UserWarning: External use of disableDASHVideo() is deprecated. It is now handled by module settings
                                              warnings.warn("External use of disableDASHVideo() is deprecated. It is now handled by module settings")
00:28:46 T:7180  NOTICE: reddit_tv:might have video=true http://www.4tube.com/videos/209271/hurry-fuck-i-bored
00:28:46 T:7180  NOTICE: script.module.youtube.dl: ERROR: _getYoutubeDLVideo() failed
00:28:46 T:7180  NOTICE: script.module.youtube.dl: _getYoutubeDLVideo() failed::getVideoInfo (362) - attribute of type 'NoneType' is not callable
00:28:46 T:7180  NOTICE: reddit_tv:can't get getVideoInfo
00:28:47 T:6640   ERROR: Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.reddit_tv/?url=http%3A%2F%2Fwww.4tube.com%2Fvideos%2F209271%2Fhurry-fuck-i-bored&mode=playYoutube_dlVideo&content_type=video]
I'm going through the list of supported sites. Some videos play and some videos don't.
I know it is a pain to keep all those sites supported so it is no big deal if some don't play.
I just want to know if I missed something or is there is anything else I can do to make the video play?


RE: [Module] youtube-dl - multi-site playable URL resolver - paper - 2016-06-12

Hi,

I'm getting interesting errors from YDStreamExtractor.getVideoInfo() which returns None:

Code:
00:52:28 5445.615723 T:1388299328  NOTICE: script.module.youtube.dl: ERROR: _getYoutubeDLVideo() failed
00:52:28 5445.616211 T:1388299328  NOTICE: script.module.youtube.dl: _getYoutubeDLVideo() failed::getVideoInfo (362) - attribute of type 'NoneType' is not callable
00:52:28 5445.618652 T:1388299328   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.Exception'>
                                            Error Contents: YDStreamExtractor.getVideoInfo("https://livestream.com/nrl/roostersstorm2016") returned None
                                            Traceback (most recent call last):
                                              File "/storage/.kodi/addons/plugin.video.nrl/addon.py", line 50, in <module>
                                                raise Exception('YDStreamExtractor.getVideoInfo("{}") returned None'.format(url))
                                            Exception: YDStreamExtractor.getVideoInfo("https://livestream.com/nrl/roostersstorm2016") returned None
                                            -->End of Python script error report<--

I'm running it on OpenELEC and what's interesting is that if I reboot it, the first time I'm trying to open the item in the plugin it works perfectly. But if I try to open this or any another item in the plugin it fails with this error until I reboot it again.

Does anyone has the same experience and maybe knows how to fix it?


RE: [Module] youtube-dl - multi-site playable URL resolver - ruuk - 2016-06-12

(2016-05-31, 09:36)d0rax Wrote: Hello ruuk, very nice addon.

Just discovered youtube-dl and am using it to expand the supported videos on my addon.

This is the code I use:
Code:
def playYoutube_dlVideo(url, name, type):
    #url = "http://www.youtube.com/watch?v=_yVv9dx88x0"   #a youtube ID will work as well and of course you could pass the url of another site
    url='http://www.220.ro/funny/Cocalarus-Retardus/cEWvAHMxuc/'
    url='http://www.3sat.de/mediathek/?mode=play&obj=51264'
    url='http://www.4tube.com/videos/209271/hurry-fuck-i-bored'
    choices = []
    stream_url=""

    if YDStreamExtractor.mightHaveVideo(url,resolve_redirects=True):
        log('might have video=true ' + url)
        vid = YDStreamExtractor.getVideoInfo(url,quality=1,resolve_redirects=True)  #quality is 0=SD, 1=720p, 2=1080p and is a maximum
        
        if vid:
            log("vid is true")
            if vid.hasMultipleStreams():
                log("vid hasMultipleStreams")
                for s in vid.streams():
                    title = s['title']
                    log('choices' + title  )
                    choices.append(title)
                #index = some_function_asking_the_user_to_choose(choices)
                vid.selectStream(0) #You can also pass in the the dict for the chosen stream
    
            stream_url = vid.streamURL()                         #This is what Kodi (XBMC) will play        
            log("stream_url="+stream_url)
            listitem = xbmcgui.ListItem(path=stream_url)
            xbmcplugin.setResolvedUrl(pluginhandle, True, listitem)
        else:
            log("can't get getVideoInfo")

I get this error:
Code:
00:28:46 T:7180  NOTICE: script.module.youtube.dl: youtube_dl core version: 2016.05.21.2
00:28:46 T:7180   ERROR: C:\Users\dorpc\AppData\Roaming\Kodi\addons\script.module.youtube.dl\lib\YDStreamExtractor.py:441: UserWarning: External use of disableDASHVideo() is deprecated. It is now handled by module settings
                                              warnings.warn("External use of disableDASHVideo() is deprecated. It is now handled by module settings")
00:28:46 T:7180  NOTICE: reddit_tv:might have video=true http://www.4tube.com/videos/209271/hurry-fuck-i-bored
00:28:46 T:7180  NOTICE: script.module.youtube.dl: ERROR: _getYoutubeDLVideo() failed
00:28:46 T:7180  NOTICE: script.module.youtube.dl: _getYoutubeDLVideo() failed::getVideoInfo (362) - attribute of type 'NoneType' is not callable
00:28:46 T:7180  NOTICE: reddit_tv:can't get getVideoInfo
00:28:47 T:6640   ERROR: Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.reddit_tv/?url=http%3A%2F%2Fwww.4tube.com%2Fvideos%2F209271%2Fhurry-fuck-i-bored&mode=playYoutube_dlVideo&content_type=video]
I'm going through the list of supported sites. Some videos play and some videos don't.
I know it is a pain to keep all those sites supported so it is no big deal if some don't play.
I just want to know if I missed something or is there is anything else I can do to make the video play?
Well, this add-on is just a wrapper around youtube-dl, so I have no control over which sites work other than updating the core to the latest version.

If you have something that works with the latest command line version of youtube-dl but not the add-on, let me know and I'll update the core.

The only other way to get sites to work is to contribute fixes to the youtube-dl project on GitHub.

Sent from my SM-N910P


RE: [Module] youtube-dl - multi-site playable URL resolver - ruuk - 2016-06-12

(2016-06-12, 01:05)paper Wrote: Hi,

I'm getting interesting errors from YDStreamExtractor.getVideoInfo() which returns None:

Code:
00:52:28 5445.615723 T:1388299328  NOTICE: script.module.youtube.dl: ERROR: _getYoutubeDLVideo() failed
00:52:28 5445.616211 T:1388299328  NOTICE: script.module.youtube.dl: _getYoutubeDLVideo() failed::getVideoInfo (362) - attribute of type 'NoneType' is not callable
00:52:28 5445.618652 T:1388299328   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.Exception'>
                                            Error Contents: YDStreamExtractor.getVideoInfo("https://livestream.com/nrl/roostersstorm2016") returned None
                                            Traceback (most recent call last):
                                              File "/storage/.kodi/addons/plugin.video.nrl/addon.py", line 50, in <module>
                                                raise Exception('YDStreamExtractor.getVideoInfo("{}") returned None'.format(url))
                                            Exception: YDStreamExtractor.getVideoInfo("https://livestream.com/nrl/roostersstorm2016") returned None
                                            -->End of Python script error report<--

I'm running it on OpenELEC and what's interesting is that if I reboot it, the first time I'm trying to open the item in the plugin it works perfectly. But if I try to open this or any another item in the plugin it fails with this error until I reboot it again.

Does anyone has the same experience and maybe knows how to fix it?

I tried the URL shown in the log snippet you posted with the latest version on youtube-dl on the command line and it failed.

Either the add-on that is using this module is passing a URL that won't work, or support for the site is currently broken. In any case the author of the add-on with the ID of plugin.video.nrl is the one to talk to.

Sent from my SM-N910P


RE: [Module] youtube-dl - multi-site playable URL resolver - paper - 2016-06-13

(2016-06-12, 23:27)ruuk Wrote: I tried the URL shown in the log snippet you posted with the latest version on youtube-dl on the command line and it failed.
I tried with the latest version available in Ubuntu and it works for me:
Code:
[email protected]:~/temp$ youtube-dl --version
2016.02.22
[email protected]:~/temp$ youtube-dl https://livestream.com/nrl/roostersstorm2016
[livestream] Downloading JSON metadata
[livestream] 5507510: Downloading page 1
[livestream] 5507510: Downloading page 2
[download] Downloading playlist: Roosters v Storm
[livestream] playlist Roosters v Storm: Collected 1 video ids (downloading 1 of them)
[download] Downloading video 1 of 1
[livestream] 125951199: Downloading JSON metadata
[livestream] 125951199: Downloading SMIL file
/usr/lib/python2.7/dist-packages/youtube_dl/extractor/livestream.py:67: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  base = base_ele.get('content') if base_ele else 'http://livestreamvod-f.akamaihd.net/'
[livestream] 125951199: Downloading m3u8 information
[livestream] 125951199: Downloading f4m manifest
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 1186
[download] Destination: Roosters v Storm-125951199.mp4
[download]   0.4% of ~2.00GiB at  5.22MiB/s ETA 10:28^C
ERROR: Interrupted by user
(2016-06-12, 23:27)ruuk Wrote: Either the add-on that is using this module is passing a URL that won't work, or support for the site is currently broken. In any case the author of the add-on with the ID of plugin.video.nrl is the one to talk to.
But why is it always working first time after reboot and not working afterwards?
Here's code to that addon:
https://bitbucket.org/older/plugin.video.nrl/src/02039c178bac94a386418e9799971db531752fcf/addon.py?fileviewer=file-view-default#addon.py-47
Module is passing exactly that same URL which is visible in the error message.


RE: [Module] youtube-dl - multi-site playable URL resolver - ruuk - 2016-06-13

(2016-06-13, 01:05)paper Wrote:
(2016-06-12, 23:27)ruuk Wrote: I tried the URL shown in the log snippet you posted with the latest version on youtube-dl on the command line and it failed.
I tried with the latest version available in Ubuntu and it works for me:
Code:
[email protected]:~/temp$ youtube-dl --version
2016.02.22
[email protected]:~/temp$ youtube-dl https://livestream.com/nrl/roostersstorm2016
[livestream] Downloading JSON metadata
[livestream] 5507510: Downloading page 1
[livestream] 5507510: Downloading page 2
[download] Downloading playlist: Roosters v Storm
[livestream] playlist Roosters v Storm: Collected 1 video ids (downloading 1 of them)
[download] Downloading video 1 of 1
[livestream] 125951199: Downloading JSON metadata
[livestream] 125951199: Downloading SMIL file
/usr/lib/python2.7/dist-packages/youtube_dl/extractor/livestream.py:67: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  base = base_ele.get('content') if base_ele else 'http://livestreamvod-f.akamaihd.net/'
[livestream] 125951199: Downloading m3u8 information
[livestream] 125951199: Downloading f4m manifest
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 1186
[download] Destination: Roosters v Storm-125951199.mp4
[download]   0.4% of ~2.00GiB at  5.22MiB/s ETA 10:28^C
ERROR: Interrupted by user
(2016-06-12, 23:27)ruuk Wrote: Either the add-on that is using this module is passing a URL that won't work, or support for the site is currently broken. In any case the author of the add-on with the ID of plugin.video.nrl is the one to talk to.
But why is it always working first time after reboot and not working afterwards?
Here's code to that addon:
https://bitbucket.org/older/plugin.video.nrl/src/02039c178bac94a386418e9799971db531752fcf/addon.py?fileviewer=file-view-default#addon.py-47
Module is passing exactly that same URL which is visible in the error message.

Hmm. The version you tried is 4 months old.

It's hard to guess why you get the behavior you described. If you could enable debug logging in the 'youtube-dl control' settings in program addons (go ahead and enable the verbose logging as well) and get me a full log I'll take a look at that and see what I can see.

Sent from my SM-N910P


RE: [Module] youtube-dl - multi-site playable URL resolver - PiMONSTER - 2016-06-23

Hi
I like this addon via osmc but it's stopped working I'm getting 'control error' on launch

It seems to be looking for a skin which doesn't exist
There is no dir /resources/skins/main

From kodi.log

18:53:30 957.557800 T:2786849776 NOTICE: Display resolution USER : 1920x1080 (1920x1080) @ 60.00i - Full Screen (28)
18:53:31 957.678101 T:2786849776 WARNING: CRenderManager::WaitForBuffer - timeout waiting for buffer
18:53:56 983.252625 T:2572153840 WARNING: Previous line repeats 1 times.
18:53:56 983.253174 T:2572153840 WARNING: CSkinInfo: failed to load skin settings
18:53:56 983.253967 T:2572153840 ERROR: GetDirectory - Error getting /home/osmc/.kodi/addons/script.module.youtube.dl/resources/skins/main
18:53:56 983.255493 T:2572153840 ERROR: EXCEPTION: XML File for Window is missing
18:53:56 983.259216 T:2572153840 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.RuntimeError'>
Error Contents: XML File for Window is missing
Traceback (most recent call last):
File "/home/osmc/.kodi/addons/script.module.youtube.dl/control.py", line 143, in <module>
main()
File "/home/osmc/.kodi/addons/script.module.youtube.dl/control.py", line 60, in __init__
showOptions(self)
File "/home/osmc/.kodi/addons/script.module.youtube.dl/control.py", line 27, in showOptions
util.ADDON.getAddonInfo('path'), 'main', '720p', main=main
RuntimeError: XML File for Window is missing
-->End of Python script error report<--
18:54:09 995.897461 T:2820666352 WARNING: CSkinInfo: failed to load skin settings
18:54:09 996.204651 T:2820666352 ERROR: EXCEPTION: Non-Existent Control 300
18:55:23 1070.148071 T:2563765232 WARNING: CPythonInvoker(13): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
18:56:53 1159.784180 T:2563765232 WARNING: CPythonInvoker(14): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
19:05:41 1688.114258 T:2820666352 WARNING: CSkinInfo: failed to load skin settings
19:05:41 1688.439819 T:2820666352 ERROR: EXCEPTION: Non-Existent Control 300
19:05:57 1704.457031 T:2629825520 WARNING: CPythonInvoker(16): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.


RE: [Module] youtube-dl - multi-site playable URL resolver - ruuk - 2016-06-23

(2016-06-23, 21:05)PiMONSTER Wrote: Hi
I like this addon via osmc but it's stopped working I'm getting 'control error' on launch

It seems to be looking for a skin which doesn't exist
There is no dir /resources/skins/main

From kodi.log...

There appears to be something wrong with your install. Try un-installing and the re-installing. That path is in fact in the addon.


RE: [Module] youtube-dl - multi-site playable URL resolver - PiMONSTER - 2016-06-28

Reinstalling worked for a day or so BUT ................. now it's gone back to it's "occasional but regular" problem of downloading to it's temp dir + saying completed successfully THEN deleting it !
Rebooted several times, freed up space and it's still doing this. Kodi log.


00:18:39 20249.062500 T:2555376624 NOTICE: script.module.youtube.dl: youtube_dl core version: 2016.05.21.2
00:18:40 20250.279297 T:2544890864 WARNING: CPythonInvoker(21): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
00:18:51 20260.767578 T:2544890864 NOTICE: script.module.youtube.dl: youtube_dl core version: 2016.05.21.2
00:18:51 20260.787109 T:2544890864 NOTICE: script.module.youtube.dl: DOWNLOAD SERVICE: START
00:18:51 20260.794922 T:2544890864 NOTICE: script.module.youtube.dl: Loading from queue. #1 this session
00:18:51 20261.335938 T:2603611120 NOTICE: Traceback (most recent call last):
File "/home/osmc/.kodi/addons/script.module.youtube.dl/lib/YDStreamExtractor.py", line 219, in _actualGetExtension
res = conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1073, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 415, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 379, in _read_status
raise BadStatusLine(line)
BadStatusLine: ''
00:18:51 20261.378906 T:2603611120 ERROR: [debug] Encodings: locale ANSI_X3.4-1968, fs ANSI_X3.4-1968, out missing (instance), pref ANSI_X3.4-1968
00:18:51 20261.378906 T:2603611120 NOTICE: .
00:18:51 20261.380859 T:2603611120 ERROR: [debug] youtube-dl version 2016.05.21.2
00:18:51 20261.380859 T:2603611120 NOTICE: .
00:18:52 20261.753906 T:2603611120 ERROR: [debug] Python version 2.7.9 - Linux-4.4.13-5-osmc-armv6l-with-debian-8.0
00:18:52 20261.753906 T:2603611120 NOTICE: .
00:18:53 20262.730469 T:2603611120 ERROR: [debug] exe versions: none
00:18:53 20262.730469 T:2603611120 NOTICE: .
00:18:53 20262.732422 T:2603611120 ERROR: [debug] Proxy map: {}
00:18:53 20262.732422 T:2603611120 NOTICE: .
00:23:07 20516.843750 T:2544890864 NOTICE: script.module.youtube.dl: DOWNLOAD SERVICE: FINISHED


As you can see it says FINISHED but it's no longer in it's temp dir and not moved to the download dir (both on same local storage plenty of space).
Also sometimes it just leaves it in it's temp dir.


RE: [Module] youtube-dl - multi-site playable URL resolver - woodside - 2016-06-28

Just a heads up... none of the vevos from Youtube are working anymore.


RE: [Module] youtube-dl - multi-site playable URL resolver - mac1202 - 2016-06-28

Hi, When I use mpv (that also use youtube-dl) to open a youtube url if the video has closed caption I can select then in mpv. Is it possible to do the same thing with kodi and your addon ?


RE: [Module] youtube-dl - multi-site playable URL resolver - ruuk - 2016-06-28

(2016-06-28, 02:20)PiMONSTER Wrote: Reinstalling worked for a day or so BUT ................. now it's gone back to it's "occasional but regular" problem of downloading to it's temp dir + saying completed successfully THEN deleting it !
Rebooted several times, freed up space and it's still doing this. Kodi log.

...

As you can see it says FINISHED but it's no longer in it's temp dir and not moved to the download dir (both on same local storage plenty of space).
Also sometimes it just leaves it in it's temp dir.

The addon downloads the file, copies it to the download path with the xbmcvfs command, and then deletes the file from the temp directory. Most likely the copy is failing for some reason. The xbmcvfs.copy() command doesn't give any errors, it just returns whether it was successful or not. I've just changed the code so that if the copy returns as failed it will not delete the temp file and will show a message (this will be in the next version). As far as why it fails to copy, that I can't tell you. Perhaps for some reason that folder is not writable by Kodi. I have no way of knowing.

Also, just FYI the 'DOWNLOAD SERVICE: FINISHED' message in the log just means the background service is done, and has nothing to do with the actual download.
If it leaves it in the temp dir (in the version you have) that likely means there was some sort of error before it gets to the code to 'move' the file. I would need a log after that happens to fix something like that.


RE: [Module] youtube-dl - multi-site playable URL resolver - ruuk - 2016-06-28

(2016-06-28, 18:14)woodside Wrote: Just a heads up... none of the vevos from Youtube are working anymore.

I'll update to the latest youtube-dl version. Hopefully it's fixed there.

(2016-06-28, 18:41)mac1202 Wrote: Hi, When I use mpv (that also use youtube-dl) to open a youtube url if the video has closed caption I can select then in mpv. Is it possible to do the same thing with kodi and your addon ?

The addon just resolves page URLs into playable URLs. If the Kodi can get closed captions from the video and you have the correct settings enabled, then yes. The ability to have CC has nothing to do with the addon.


v16.627.0 - ruuk - 2016-06-28

Version 16.627.0

Changes:
  • Updated youtube-dl core to 2016.06.27
  • Downloads that fail to copy from temp to downloads now are kept in temp with a message

On Kodi repo, pending mirror updates.


RE: [Module] youtube-dl - multi-site playable URL resolver - mac1202 - 2016-06-28

(2016-06-28, 19:50)ruuk Wrote: The addon just resolves page URLs into playable URLs. If the Kodi can get closed captions from the video and you have the correct settings enabled, then yes. The ability to have CC has nothing to do with the addon.

In fact it has something to do with the addon, because youtube subtitle are not embedded within the video. They are external vtt files and you have to invoke the youtube-dl program with the "--write-srt" option to detect and download them and i wonder if there is a way for you addon to pass this subtitle files to kodi ?


This forum uses Lukasz Tkacz MyBB addons.