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
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)?
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 dataWhat'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
And the following procedure handles resolving the link using the youtube-dl module
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)?