|
|
@ -260,6 +260,132 @@ def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = "
|
|
|
|
return url
|
|
|
|
return url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated = false)
|
|
|
|
|
|
|
|
if !auto_generated
|
|
|
|
|
|
|
|
cursor = Base64.urlsafe_encode(cursor, false)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta = IO::Memory.new
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if auto_generated
|
|
|
|
|
|
|
|
meta.write(Bytes[0x08, 0x0a])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x12, 0x09])
|
|
|
|
|
|
|
|
meta.print("playlists")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if auto_generated
|
|
|
|
|
|
|
|
meta.write(Bytes[0x20, 0x32])
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# TODO: Look at 0x01, 0x00
|
|
|
|
|
|
|
|
case sort
|
|
|
|
|
|
|
|
when "oldest", "oldest_created"
|
|
|
|
|
|
|
|
meta.write(Bytes[0x18, 0x02])
|
|
|
|
|
|
|
|
when "newest", "newest_created"
|
|
|
|
|
|
|
|
meta.write(Bytes[0x18, 0x03])
|
|
|
|
|
|
|
|
when "last", "last_added"
|
|
|
|
|
|
|
|
meta.write(Bytes[0x18, 0x04])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x20, 0x01])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x30, 0x02])
|
|
|
|
|
|
|
|
meta.write(Bytes[0x38, 0x01])
|
|
|
|
|
|
|
|
meta.write(Bytes[0x60, 0x01])
|
|
|
|
|
|
|
|
meta.write(Bytes[0x6a, 0x00])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x7a, cursor.size])
|
|
|
|
|
|
|
|
meta.print(cursor)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0xb8, 0x01, 0x00])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta.rewind
|
|
|
|
|
|
|
|
meta = Base64.urlsafe_encode(meta.to_slice)
|
|
|
|
|
|
|
|
meta = URI.escape(meta)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation = IO::Memory.new
|
|
|
|
|
|
|
|
continuation.write(Bytes[0x12, ucid.size])
|
|
|
|
|
|
|
|
continuation.print(ucid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation.write(Bytes[0x1a])
|
|
|
|
|
|
|
|
continuation.write(write_var_int(meta.size))
|
|
|
|
|
|
|
|
continuation.print(meta)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation.rewind
|
|
|
|
|
|
|
|
continuation = continuation.gets_to_end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapper = IO::Memory.new
|
|
|
|
|
|
|
|
wrapper.write(Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02])
|
|
|
|
|
|
|
|
wrapper.write(write_var_int(continuation.size))
|
|
|
|
|
|
|
|
wrapper.print(continuation)
|
|
|
|
|
|
|
|
wrapper.rewind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapper = Base64.urlsafe_encode(wrapper.to_slice)
|
|
|
|
|
|
|
|
wrapper = URI.escape(wrapper)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = "/browse_ajax?continuation=#{wrapper}&gl=US&hl=en"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return url
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def extract_channel_playlists_cursor(url, auto_generated)
|
|
|
|
|
|
|
|
wrapper = HTTP::Params.parse(URI.parse(url).query.not_nil!)["continuation"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapper = URI.unescape(wrapper)
|
|
|
|
|
|
|
|
wrapper = Base64.decode(wrapper)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 0xe2 0xa9 0x85 0xb2 0x02
|
|
|
|
|
|
|
|
wrapper += 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation_size = read_var_int(wrapper[0, 4])
|
|
|
|
|
|
|
|
wrapper += write_var_int(continuation_size).size
|
|
|
|
|
|
|
|
continuation = wrapper[0, continuation_size]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 0x12
|
|
|
|
|
|
|
|
continuation += 1
|
|
|
|
|
|
|
|
ucid_size = continuation[0]
|
|
|
|
|
|
|
|
continuation += 1
|
|
|
|
|
|
|
|
ucid = continuation[0, ucid_size]
|
|
|
|
|
|
|
|
continuation += ucid_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 0x1a
|
|
|
|
|
|
|
|
continuation += 1
|
|
|
|
|
|
|
|
meta_size = read_var_int(continuation[0, 4])
|
|
|
|
|
|
|
|
continuation += write_var_int(meta_size).size
|
|
|
|
|
|
|
|
meta = continuation[0, meta_size]
|
|
|
|
|
|
|
|
continuation += meta_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta = String.new(meta)
|
|
|
|
|
|
|
|
meta = URI.unescape(meta)
|
|
|
|
|
|
|
|
meta = Base64.decode(meta)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 0x12 0x09 playlists
|
|
|
|
|
|
|
|
meta += 11
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
until meta[0] == 0x7a
|
|
|
|
|
|
|
|
tag = read_var_int(meta[0, 4])
|
|
|
|
|
|
|
|
meta += write_var_int(tag).size
|
|
|
|
|
|
|
|
value = meta[0]
|
|
|
|
|
|
|
|
meta += 1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 0x7a
|
|
|
|
|
|
|
|
meta += 1
|
|
|
|
|
|
|
|
cursor_size = meta[0]
|
|
|
|
|
|
|
|
meta += 1
|
|
|
|
|
|
|
|
cursor = meta[0, cursor_size]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor = String.new(cursor)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !auto_generated
|
|
|
|
|
|
|
|
cursor = URI.unescape(cursor)
|
|
|
|
|
|
|
|
cursor = Base64.decode_string(cursor)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cursor
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def get_about_info(ucid, locale)
|
|
|
|
def get_about_info(ucid, locale)
|
|
|
|
client = make_client(YT_URL)
|
|
|
|
client = make_client(YT_URL)
|
|
|
|
|
|
|
|
|
|
|
@ -290,7 +416,7 @@ def get_about_info(ucid, locale)
|
|
|
|
sub_count ||= 0
|
|
|
|
sub_count ||= 0
|
|
|
|
|
|
|
|
|
|
|
|
author = about.xpath_node(%q(//span[contains(@class,"qualified-channel-title-text")]/a)).not_nil!.content
|
|
|
|
author = about.xpath_node(%q(//span[contains(@class,"qualified-channel-title-text")]/a)).not_nil!.content
|
|
|
|
ucid = about.xpath_node(%q(//link[@rel="canonical"])).not_nil!["href"].split("/")[-1]
|
|
|
|
ucid = about.xpath_node(%q(//meta[@itemprop="channelId"])).not_nil!["content"]
|
|
|
|
|
|
|
|
|
|
|
|
# Auto-generated channels
|
|
|
|
# Auto-generated channels
|
|
|
|
# https://support.google.com/youtube/answer/2579942
|
|
|
|
# https://support.google.com/youtube/answer/2579942
|
|
|
|