gitagogaming / Youtube-TouchPortal-Plugin

Control your YouTube Live Stream with TouchPortal!
6 stars 0 forks source link

Retrieve Game Title of YouTube video #14

Closed gitagogaming closed 1 year ago

gitagogaming commented 1 year ago

create an action which allows the user to retrieve the game title set on their live stream video...

this info is not available by default in the youtube API so instead we parse webpage content to get the info when its available BUT this will use up extra bandwidth if put on "auto" and I dont like that idea...

import urllib.request

def getURL(url):
    return urllib.request.urlopen(url).read().decode('utf-8')

videoId = 'CjvfYn5TkQU'
url = 'https://www.youtube.com/watch?v=' + videoId
content = getURL(url)
prefix = '}]},"title":{"simpleText":"'
if prefix in content:
    gameName = content.split(prefix)[1].split('"')[0]
    print(gameName)
gitagogaming commented 1 year ago

Not going to implement until users request