ruuk / script.module.youtube.dl

⛔️ DEPRECATED: Access to youtube-dl stream extraction in an XBMC module
GNU General Public License v2.0
39 stars 40 forks source link

Youtube videos from .htm links failing to resolve #19

Open caffeinatedMike opened 7 years ago

caffeinatedMike commented 7 years ago

When trying to resolve links ending in .htm, which are in a directory created in a loop from a list of all my collected links, the youtube links that are collected always fail. Below is the relevant log data

11:50:34.261 T:7784   DEBUG: CGUIWindowVideoBase::OnPlayMedia plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Fwho-wants-to-go-for-a-walk.htm
11:50:34.261 T:7232   DEBUG: CAnnouncementManager - Announcement: OnClear from xbmc
11:50:34.261 T:7232   DEBUG: GOT ANNOUNCEMENT, type: 2, from xbmc, message OnClear
11:50:34.261 T:7232   DEBUG: CAnnouncementManager - Announcement: OnAdd from xbmc
11:50:34.261 T:7232   DEBUG: GOT ANNOUNCEMENT, type: 2, from xbmc, message OnAdd
11:50:34.261 T:7784   DEBUG: XFILE::CPluginDirectory::StartScript - calling plugin Squeee!('plugin://plugin.video.Squeee/','4','?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Fwho-wants-to-go-for-a-walk.htm')
11:50:34.265 T:7460   DEBUG: Thread LanguageInvoker start, auto delete: false
11:50:34.267 T:7460    INFO: initializing python engine.
11:50:34.267 T:7460   DEBUG: CPythonInvoker(12, E:\Kodi\portable_data\addons\plugin.video.Squeee\addon.py): start processing
11:50:34.285 T:6532   DEBUG: Thread scriptobs start, auto delete: false
11:50:34.485 T:7784   DEBUG: ------ Window Init (DialogBusy.xml) ------
11:50:34.513 T:7460   DEBUG: -->Python Interpreter Initialized<--
11:50:34.513 T:7460   DEBUG: CPythonInvoker(12, E:\Kodi\portable_data\addons\plugin.video.Squeee\addon.py): the source file to load is "E:\Kodi\portable_data\addons\plugin.video.Squeee\addon.py"
11:50:34.514 T:7460   DEBUG: CPythonInvoker(12, E:\Kodi\portable_data\addons\plugin.video.Squeee\addon.py): setting the Python path to E:\Kodi\portable_data\addons\plugin.video.Squeee;E:\Kodi\portable_data\addons\script.module.addon.signals\lib;E:\Kodi\portable_data\addons\script.module.beautifulsoup\lib;E:\Kodi\portable_data\addons\script.module.requests\lib;E:\Kodi\portable_data\addons\script.module.youtube.dl\lib;E:\Kodi\system\python\DLLs;E:\Kodi\system\python\Lib;E:\Kodi\python27.zip;E:\Kodi\system\python\lib\plat-win;E:\Kodi\system\python\lib\lib-tk;E:\Kodi;E:\Kodi\system\python;E:\Kodi\system\python\lib\site-packages
11:50:34.514 T:7460   DEBUG: CPythonInvoker(12, E:\Kodi\portable_data\addons\plugin.video.Squeee\addon.py): entering source directory E:\Kodi\portable_data\addons\plugin.video.Squeee
11:50:34.516 T:7460   DEBUG: CPythonInvoker(12, E:\Kodi\portable_data\addons\plugin.video.Squeee\addon.py): instantiating addon using automatically obtained id of "plugin.video.Squeee" dependent on version 2.1.0 of the xbmc.python api
11:50:37.544 T:10136   DEBUG: Thread JobWorker 10136 terminating (autodelete)
11:50:39.266 T:7784   DEBUG: ------ Window Deinit (Pointer.xml) ------
11:50:41.728 T:3112   DEBUG: Thread JobWorker 3112 terminating (autodelete)
11:50:41.781 T:5956   DEBUG: Thread JobWorker 5956 terminating (autodelete)
11:50:41.839 T:7460  NOTICE: script.module.youtube.dl: youtube_dl core version: 2017.05.18.1
11:50:43.030 T:7784   DEBUG: Activating window ID: 10138
11:50:45.363 T:7784   DEBUG: CWinEventsWin32::WndProcWindow is active
11:50:45.363 T:7784   DEBUG: CWinEventsWin32::WndProc: Focus switched to process C:\Users\mhill\Desktop\ffmpeg\bin\ffmpeg.exe
11:50:45.430 T:7784   DEBUG: CWinEventsWin32::WndProcWindow is active
11:50:46.179 T:7784   DEBUG: Previous line repeats 1 times.
11:50:46.179 T:7784   DEBUG: CWinEventsWin32::WndProc: Focus switched to process C:\Users\mhill\Desktop\ffmpeg\bin\ffprobe.exe
11:50:46.243 T:7460    INFO: CPythonInvoker(12, E:\Kodi\portable_data\addons\plugin.video.Squeee\addon.py): script successfully run
11:50:46.258 T:6532   DEBUG: Thread scriptobs 6532 terminating
11:50:46.258 T:7784    INFO: XCURL::DllLibCurlGlobal::easy_aquire - Created session to https://www.youtube.com
11:50:47.213 T:7460    INFO: Python script stopped
11:50:47.214 T:7460   DEBUG: Thread LanguageInvoker 7460 terminating
11:50:47.781 T:7784   DEBUG: CCurlFile::GetMimeType - https://www.youtube.com/watch?v=XZpOghdjZaA|User-Agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A10.0%29+Gecko%2F20150101+Firefox%2F47.0+%28Chrome%29 -> x-directory/normal
11:50:47.789 T:7784   DEBUG: Loading settings for https://www.youtube.com/watch?v=XZpOghdjZaA|User-Agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A10.0%29+Gecko%2F20150101+Firefox%2F47.0+%28Chrome%29
11:50:47.792 T:7784   DEBUG: CPlayerCoreFactory::GetPlayers(https://www.youtube.com/watch?v=XZpOghdjZaA|User-Agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A10.0%29+Gecko%2F20150101+Firefox%2F47.0+%28Chrome%29)
11:50:47.792 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: system rules
11:50:47.792 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: matches rule: system rules
11:50:47.792 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: mms/udp
11:50:47.792 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: lastfm/shout
11:50:47.792 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: rtmp
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: rtsp
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: streams
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: matches rule: streams
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: aacp/sdp
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: mp2
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: dvd
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: dvdimage
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: sdp/asf
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: nsv
11:50:47.793 T:7784   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: radio
11:50:47.793 T:7784   DEBUG: CPlayerCoreFactory::GetPlayers: matched 0 rules with players
11:50:47.793 T:7784   DEBUG: CPlayerCoreFactory::GetPlayers: adding videodefaultplayer (VideoPlayer)
11:50:47.793 T:7784   DEBUG: CPlayerCoreFactory::GetPlayers: for video=1, audio=0
11:50:47.793 T:7784   DEBUG: CPlayerCoreFactory::GetPlayers: for video=1, audio=1
11:50:47.793 T:7784   DEBUG: CPlayerCoreFactory::GetPlayers: added 1 players
11:50:47.795 T:7784   DEBUG: Radio UECP (RDS) Processor - new CDVDRadioRDSData::CDVDRadioRDSData
11:50:47.795 T:7784  NOTICE: VideoPlayer: Opening: https://www.youtube.com/watch?v=XZpOghdjZaA|User-Agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A10.0%29+Gecko%2F20150101+Firefox%2F47.0+%28Chrome%29
11:50:47.795 T:7784 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
11:50:48.119 T:7784   DEBUG: CCurlFile::GetMimeType - https://www.youtube.com/watch?v=XZpOghdjZaA|User-Agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A10.0%29+Gecko%2F20150101+Firefox%2F47.0+%28Chrome%29 -> x-directory/normal
11:50:48.119 T:7784   ERROR: DXVA::CProcessorHD::IsFormatSupported: Unsupported format 104 for 1.
11:50:48.119 T:7784   ERROR: DXVA::CProcessorHD::IsFormatSupported: Unsupported format 105 for 1.
11:50:48.119 T:4348   DEBUG: Thread VideoPlayer start, auto delete: false
11:50:48.120 T:4348  NOTICE: Creating InputStream
11:50:48.120 T:4348   DEBUG: CurlFile::Open(0738F16C) https://www.youtube.com/watch?v=XZpOghdjZaA
11:50:48.244 T:4348   DEBUG: CFileCache::Open - opening <watch> using cache
11:50:48.245 T:4348   DEBUG: CurlFile::Open(12A326A0) https://www.youtube.com/watch?v=XZpOghdjZaA
11:50:48.351 T:4348  NOTICE: Creating Demuxer
11:50:48.351 T:3656   DEBUG: Thread FileCache start, auto delete: false
11:50:48.619 T:7784   DEBUG: ------ Window Init (DialogBusy.xml) ------
11:50:48.620 T:7784   DEBUG: CWinEventsWin32::WndProcWindow is active
11:50:48.625 T:7784   DEBUG: ------ Window Deinit (DialogBusy.xml) ------
11:50:48.631 T:3656    INFO: CFileCache::Process - Source read didn't return any data! Hit eof(?)
11:50:48.664 T:4348   ERROR: CDVDDemuxFFmpeg::Open - error probing input format, https://www.youtube.com/watch?v=XZpOghdjZaA
11:50:48.664 T:4348   ERROR: CVideoPlayer::OpenDemuxStream - Error creating demuxer
11:50:48.664 T:4348  NOTICE: CVideoPlayer::OnExit()
11:50:48.664 T:3656   DEBUG: Thread FileCache 3656 terminating
11:50:48.665 T:4348   DEBUG: CApplication::OnPlayBackStopped: play state was 1, starting 1
11:50:48.665 T:4348   DEBUG: Thread VideoPlayer 4348 terminating
11:50:48.678 T:7784   DEBUG: CApplication::OnPlayBackStopped: play state was 3, starting 0
11:50:48.678 T:7784   ERROR: Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Fwho-wants-to-go-for-a-walk.htm]
11:50:48.678 T:7784   DEBUG: Playlist Player: one or more items failed to play... aborting playback
11:50:48.678 T:7232   DEBUG: CAnnouncementManager - Announcement: OnStop from xbmc

What's odd is the first link works when placed in the web browser, but kodi isn't able to play it.

Below is the portion of my code where I create the directory and provide the unresolved links

#Hard-coded url, not collected with BeautifulSoup - Works fine
    url = "http://www.thatcutesite.com/squirrel-chocolate-thief/"
    vid = YDStreamExtractor.getVideoInfo(url,quality=1) #quality is 0=SD, 1=720p, 2=1080p and is a maximum
    stream_url = vid.streamURL() #This is what Kodi (XBMC) will play
    list_item = xbmcgui.ListItem(label='Squirrel Stealing Chocolate (YDStreamExtracter)')
    url = stream_url
    is_folder = False
    list_item.setProperty('IsPlayable','true')
    xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder)

    #Site 1
    r = requests.get('http://www.dailyhaha.com/videos/animals/')
    c = r.content
    #Temporary fix
    c = c.replace("SCR' + 'IPT", "SCRIPT")
    soup = BeautifulSoup(c)

    #Get links
    outer_video_tags = soup.findAll('a', {'class': 'item video'})
    #Get video titles
    video_titles = soup.findAll('div', {'class': 'info'})
    #Get Play Count
    video_views = soup.findAll('div', {'class': 'views'})
    #Get Video Type
    video_type = soup.findAll('span', {'class': 'type'})

    #Remove extra metadata from title
    video_titles = [str(x).replace(str(video_views[video_titles.index(x)]),"").replace(str(video_type[video_titles.index(x)]),"") for x in video_titles]
    #video_titles = [str(x).replace(str(video_views[video_titles.index(x)]),"") for x in video_titles]

    unresolved_links = [link['href'] for link in outer_video_tags]

    for link in unresolved_links:
        list_item = xbmcgui.ListItem(label=str(video_titles[unresolved_links.index(link)]))
        is_folder = False
        #list_item.setProperty('Video', 'true')
        list_item.setProperty('IsPlayable','true')
        url = get_url(resolve=link)
        xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder)

    # Add a sort method for the virtual folder items (alphabetically, ignore articles)
    xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
    # Finish creating a virtual folder.
    xbmcplugin.endOfDirectory(_handle)

And the following procedure handles resolving the link using the youtube-dl module

def play_video(link):
    """
    Play a video by the provided path.
    :param path: str
    :return: None
    """

    vid = YDStreamExtractor.getVideoInfo(link,quality=1) #quality is 0=SD, 1=720p, 2=1080p and is a maximum
    stream_url = vid.streamURL() #This is what Kodi (XBMC) will play

    # Create a playable item with a path to play.
    play_item = xbmcgui.ListItem(path=stream_url)
    #play_item.setProperty('IsPlayable','true')
    # Pass the item to the Kodi player.
    xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)

Any idea what's going on? Am I doing something wrong or is this a limitation of the module (not being able to handle .htm urls)?