Skip to content

Instantly share code, notes, and snippets.

@mattwright324
Last active March 15, 2024 03:32
Show Gist options
  • Save mattwright324/cbff19bf4e5edbe25abe797bdc9de1bc to your computer and use it in GitHub Desktop.
Save mattwright324/cbff19bf4e5edbe25abe797bdc9de1bc to your computer and use it in GitHub Desktop.
yt-channel-resolver
https://www.youtube.com/@90sFilmyGaane
https://www.youtube.com/@AASTIKSpiritualSecrets
https://www.youtube.com/@acousticsound
https://www.youtube.com/@acousticsound5879
https://www.youtube.com/@actiondhamaka
https://www.youtube.com/@ActionHeroes
https://www.youtube.com/@ActionHits
https://www.youtube.com/@adityamovies
https://www.youtube.com/@AdkGujaratiProduction
https://www.youtube.com/@AkkNedlyamenya
https://www.youtube.com/@AlbSoundProduction
https://www.youtube.com/@ambeycassettes
https://www.youtube.com/@andpictureschannel
https://www.youtube.com/@andtvchannel
import requests, json
def resolveId(channelUrl):
data_json = {
"context": {
"client": {
"clientName": "ANDROID",
"clientVersion": "19.09.37",
"hl": "en"
}
},
"url": channelUrl
}
url = 'https://youtubei.googleapis.com/youtubei/v1/navigation/resolve_url?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
data = json.dumps(data_json)
res = requests.post(url, data=data, headers={"Content-Type": "application/json"})
return json.loads(res.text)["endpoint"]["browseEndpoint"]["browseId"]
file = open('channels.txt', 'r')
lines = file.readlines()
for line in lines:
url = line.strip()
try:
id = resolveId(url)
print(f'{url} --> {id}')
except:
print(f'{url} --x error resolving, 404?')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment