Open kishaningithub opened 6 years ago
ITag parser appears to be working correctly:
import urllib2
import urlparse
id = 'NTHz9ephYTw'
url = "http://www.youtube.com/get_video_info?&video_id="+ id
body = urllib2.urlopen(url).read()
query = urlparse.parse_qs(body)
stream_map = query['url_encoded_fmt_stream_map'][0]
stream_map_query = urlparse.parse_qs(stream_map)
itag = stream_map_query['itag']
print 'itags:', itag
Output:
itags: ['22', '43', '18', '36', '17']
Hi @dbatbold If you see the output from ytdl in my previous post (reposted below stripping out other unwanted details) you can see that there are more itags..
➜ bin ./ytdl -j 'https://www.youtube.com/watch?v=NTHz9ephYTw' | jq "[ .formats[].itag ]"
[
22,
43,
18,
36,
17,
137,
248,
136,
247,
135,
244,
134,
243,
133,
242,
160,
278,
140,
171,
249,
250,
251
]
Looks like ITag numbers are hard coded in https://github.com/rylio/ytdl/blob/master/format.go#L81 file.
The returned ['22', '43', '18', '36', '17']
tags are available formats that YouTube currently has for the specific video. The ytdl
tool is showing the formats that can be requested from YouTube, but it doesn't mean they have all the formats available.
If it did that i shouldn't be able to download right ? But i am able to.. Also Assuming the ytdl code is wrong.. I Tested that with time tested youtube-dl as given below
➜ bin youtube-dl -f 140 'https://www.youtube.com/watch?v=NTHz9ephYTw'
[youtube] NTHz9ephYTw: Downloading webpage
[youtube] NTHz9ephYTw: Downloading video info webpage
[youtube] NTHz9ephYTw: Extracting video information
[download] Resuming download at byte 261120
[download] Destination: Kar Gayi Chull - Kapoor & Sons _ Sidharth Malhotra _ Alia Bhatt _ Badshah _ Amaal Mallik _Fazilpuria-NTHz9ephYTw.m4a
[download] 100% of 2.15MiB in 00:02
[ffmpeg] Correcting container in "Kar Gayi Chull - Kapoor & Sons _ Sidharth Malhotra _ Alia Bhatt _ Badshah _ Amaal Mallik _Fazilpuria-NTHz9ephYTw.m4a"
As you can see itag 140 corresponds to m4a format
Whereas the output from ytdl shows otherwise