I’m trying to get YouTube working on a headless Picroft and as far as I can tell not one of those works.
I imagine it should be fairly straightforward to output a video stream to ffmpeg and have it transcode or otherwise strip out just the audio. Admittedly that does mean I need to learn how Python classes work!
do you have some issue with youtube skills to recently ? Can’t load music since 2 days, it’s telling me that no result have been found , maybe youtube update something ?
Acutally trying to debug it (lol first time I’m seeing python script). It seem that if you change skill to load only one music it’s working. So I think that the issue is with youtube-dl who can scrap youtube video because maybe youtube has made some changes
There are several youtube skills scattered throughout the community. What skill(s) are having issues. From my own testing it looks like the regex is failing on most of these due to a change in youtube. I have seen a similar issue with my Kodi-skill that I am correcting. @mcdruid may be able to assist with their skill.
@mcdruid has been MIA for a bit. Not sure if he will respond or not. If I get adventurous maybe I will see if I can get his skill working. I have an idea what needs to be done.
@mcdruid, Glad to see you are still active, I don’t have a gitlab account but have been doing a bit of playing around. There may be an issue with yt-downloader too but I am unsure since I think i have maxed out my google quota with testing I have been playing with your code and changed your search_youtube routine to this code and it seams to return valid results.
def search_youtube(self, search_term):
tracklist = []
res = requests.get(search_url + search_term)
# TODO: check status code etc...
html = res.content
soup = BeautifulSoup(html, 'html.parser')
all_vid_id = re.findall(r'/watch\?v=(.{11})', str(soup))
if len(all_vid_id) >= 1:
for vid_id in all_vid_id:
vid_url = "/watch?v=" + str(vid_id)
self.stream_url = self.get_stream_url(vid_url)
LOG.debug('Found stream URL: ' + self.stream_url)
tracklist.append(self.stream_url)
LOG.info(str(tracklist))
self.mediaplayer.add_list(tracklist)
vid_name = str(search_term)
self.audio_state = 'playing'
self.speak_dialog('now.playing', {'content': vid_name})
wait_while_speaking()
self.mediaplayer.play()
return
else:
# We didn't find any playable results
self.speak_dialog('not.found')
wait_while_speaking()
LOG.debug('Could not find any results with the query term: ' + search_term)
Ok, great so that approach is just finding the watch?v=BLAH url in the soup, and using the original search term as the title.
Enough to get something work again, but it’s a shame not to be parsing the title from the result etc…
I’ve started to look at using something like https://stackoverflow.com/a/56059878 to extract and parse the json. Looks sort of okay, but with the first search terms I’ve tried it’s failing to parse the json properly, and I’m not sure why yet…