|
|
@ -441,53 +441,57 @@ def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = "
|
|
|
|
switch = 0x00
|
|
|
|
switch = 0x00
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
meta = IO::Memory.new
|
|
|
|
data = IO::Memory.new
|
|
|
|
meta.write(Bytes[0x12, 0x06])
|
|
|
|
data.write_byte 0x12
|
|
|
|
meta.print("videos")
|
|
|
|
data.write_byte 0x06
|
|
|
|
|
|
|
|
data.print "videos"
|
|
|
|
meta.write(Bytes[0x30, 0x02])
|
|
|
|
|
|
|
|
meta.write(Bytes[0x38, 0x01])
|
|
|
|
data.write Bytes[0x30, 0x02]
|
|
|
|
meta.write(Bytes[0x60, 0x01])
|
|
|
|
data.write Bytes[0x38, 0x01]
|
|
|
|
meta.write(Bytes[0x6a, 0x00])
|
|
|
|
data.write Bytes[0x60, 0x01]
|
|
|
|
meta.write(Bytes[0xb8, 0x01, 0x00])
|
|
|
|
data.write Bytes[0x6a, 0x00]
|
|
|
|
|
|
|
|
data.write Bytes[0xb8, 0x01, 0x00]
|
|
|
|
meta.write(Bytes[0x20, switch])
|
|
|
|
|
|
|
|
meta.write(Bytes[0x7a, page.size])
|
|
|
|
data.write Bytes[0x20, switch]
|
|
|
|
meta.print(page)
|
|
|
|
data.write_byte 0x7a
|
|
|
|
|
|
|
|
VarInt.to_io(data, page.bytesize)
|
|
|
|
|
|
|
|
data.print page
|
|
|
|
|
|
|
|
|
|
|
|
case sort_by
|
|
|
|
case sort_by
|
|
|
|
when "newest"
|
|
|
|
when "newest"
|
|
|
|
# Empty tags can be omitted
|
|
|
|
# Empty tags can be omitted
|
|
|
|
# meta.write(Bytes[0x18,0x00])
|
|
|
|
# meta.write(Bytes[0x18,0x00])
|
|
|
|
when "popular"
|
|
|
|
when "popular"
|
|
|
|
meta.write(Bytes[0x18, 0x01])
|
|
|
|
data.write Bytes[0x18, 0x01]
|
|
|
|
when "oldest"
|
|
|
|
when "oldest"
|
|
|
|
meta.write(Bytes[0x18, 0x02])
|
|
|
|
data.write Bytes[0x18, 0x02]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
meta.rewind
|
|
|
|
data = Base64.urlsafe_encode(data)
|
|
|
|
meta = Base64.urlsafe_encode(meta.to_slice)
|
|
|
|
cursor = URI.escape(data)
|
|
|
|
meta = URI.escape(meta)
|
|
|
|
|
|
|
|
|
|
|
|
data = IO::Memory.new
|
|
|
|
|
|
|
|
|
|
|
|
continuation = IO::Memory.new
|
|
|
|
data.write_byte 0x12
|
|
|
|
continuation.write(Bytes[0x12, ucid.size])
|
|
|
|
VarInt.to_io(data, ucid.bytesize)
|
|
|
|
continuation.print(ucid)
|
|
|
|
data.print ucid
|
|
|
|
|
|
|
|
|
|
|
|
continuation.write(Bytes[0x1a, meta.size])
|
|
|
|
data.write_byte 0x1a
|
|
|
|
continuation.print(meta)
|
|
|
|
VarInt.to_io(data, cursor.bytesize)
|
|
|
|
|
|
|
|
data.print cursor
|
|
|
|
|
|
|
|
|
|
|
|
continuation.rewind
|
|
|
|
data.rewind
|
|
|
|
continuation = continuation.gets_to_end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapper = IO::Memory.new
|
|
|
|
buffer = IO::Memory.new
|
|
|
|
wrapper.write(Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02, continuation.size])
|
|
|
|
buffer.write Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02]
|
|
|
|
wrapper.print(continuation)
|
|
|
|
VarInt.to_io(buffer, data.bytesize)
|
|
|
|
wrapper.rewind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapper = Base64.urlsafe_encode(wrapper.to_slice)
|
|
|
|
IO.copy data, buffer
|
|
|
|
wrapper = URI.escape(wrapper)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = "/browse_ajax?continuation=#{wrapper}&gl=US&hl=en"
|
|
|
|
continuation = Base64.urlsafe_encode(buffer)
|
|
|
|
|
|
|
|
continuation = URI.escape(continuation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en"
|
|
|
|
|
|
|
|
|
|
|
|
return url
|
|
|
|
return url
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -497,117 +501,108 @@ def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated
|
|
|
|
cursor = Base64.urlsafe_encode(cursor, false)
|
|
|
|
cursor = Base64.urlsafe_encode(cursor, false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
meta = IO::Memory.new
|
|
|
|
data = IO::Memory.new
|
|
|
|
|
|
|
|
|
|
|
|
if auto_generated
|
|
|
|
if auto_generated
|
|
|
|
meta.write(Bytes[0x08, 0x0a])
|
|
|
|
data.write Bytes[0x08, 0x0a]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x12, 0x09])
|
|
|
|
data.write Bytes[0x12, 0x09]
|
|
|
|
meta.print("playlists")
|
|
|
|
data.print "playlists"
|
|
|
|
|
|
|
|
|
|
|
|
if auto_generated
|
|
|
|
if auto_generated
|
|
|
|
meta.write(Bytes[0x20, 0x32])
|
|
|
|
data.write Bytes[0x20, 0x32]
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# TODO: Look at 0x01, 0x00
|
|
|
|
# TODO: Look at 0x01, 0x00
|
|
|
|
case sort
|
|
|
|
case sort
|
|
|
|
when "oldest", "oldest_created"
|
|
|
|
when "oldest", "oldest_created"
|
|
|
|
meta.write(Bytes[0x18, 0x02])
|
|
|
|
data.write Bytes[0x18, 0x02]
|
|
|
|
when "newest", "newest_created"
|
|
|
|
when "newest", "newest_created"
|
|
|
|
meta.write(Bytes[0x18, 0x03])
|
|
|
|
data.write Bytes[0x18, 0x03]
|
|
|
|
when "last", "last_added"
|
|
|
|
when "last", "last_added"
|
|
|
|
meta.write(Bytes[0x18, 0x04])
|
|
|
|
data.write Bytes[0x18, 0x04]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x20, 0x01])
|
|
|
|
data.write Bytes[0x20, 0x01]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x30, 0x02])
|
|
|
|
data.write Bytes[0x30, 0x02]
|
|
|
|
meta.write(Bytes[0x38, 0x01])
|
|
|
|
data.write Bytes[0x38, 0x01]
|
|
|
|
meta.write(Bytes[0x60, 0x01])
|
|
|
|
data.write Bytes[0x60, 0x01]
|
|
|
|
meta.write(Bytes[0x6a, 0x00])
|
|
|
|
data.write Bytes[0x6a, 0x00]
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0x7a, cursor.size])
|
|
|
|
data.write_byte 0x7a
|
|
|
|
meta.print(cursor)
|
|
|
|
VarInt.to_io(data, cursor.bytesize)
|
|
|
|
|
|
|
|
data.print cursor
|
|
|
|
|
|
|
|
|
|
|
|
meta.write(Bytes[0xb8, 0x01, 0x00])
|
|
|
|
data.write Bytes[0xb8, 0x01, 0x00]
|
|
|
|
|
|
|
|
|
|
|
|
meta.rewind
|
|
|
|
data.rewind
|
|
|
|
meta = Base64.urlsafe_encode(meta.to_slice)
|
|
|
|
data = Base64.urlsafe_encode(data)
|
|
|
|
meta = URI.escape(meta)
|
|
|
|
continuation = URI.escape(data)
|
|
|
|
|
|
|
|
|
|
|
|
continuation = IO::Memory.new
|
|
|
|
data = IO::Memory.new
|
|
|
|
continuation.write(Bytes[0x12, ucid.size])
|
|
|
|
|
|
|
|
continuation.print(ucid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation.write(Bytes[0x1a])
|
|
|
|
data.write_byte 0x12
|
|
|
|
continuation.write(write_var_int(meta.size))
|
|
|
|
VarInt.to_io(data, ucid.bytesize)
|
|
|
|
continuation.print(meta)
|
|
|
|
data.print ucid
|
|
|
|
|
|
|
|
|
|
|
|
continuation.rewind
|
|
|
|
data.write_byte 0x1a
|
|
|
|
continuation = continuation.gets_to_end
|
|
|
|
VarInt.to_io(data, continuation.bytesize)
|
|
|
|
|
|
|
|
data.print continuation
|
|
|
|
|
|
|
|
|
|
|
|
wrapper = IO::Memory.new
|
|
|
|
data.rewind
|
|
|
|
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)
|
|
|
|
buffer = IO::Memory.new
|
|
|
|
wrapper = URI.escape(wrapper)
|
|
|
|
buffer.write Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02]
|
|
|
|
|
|
|
|
VarInt.to_io(buffer, data.bytesize)
|
|
|
|
|
|
|
|
|
|
|
|
url = "/browse_ajax?continuation=#{wrapper}&gl=US&hl=en"
|
|
|
|
IO.copy data, buffer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation = Base64.urlsafe_encode(buffer)
|
|
|
|
|
|
|
|
continuation = URI.escape(continuation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en"
|
|
|
|
|
|
|
|
|
|
|
|
return url
|
|
|
|
return url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def extract_channel_playlists_cursor(url, auto_generated)
|
|
|
|
def extract_channel_playlists_cursor(url, auto_generated)
|
|
|
|
wrapper = HTTP::Params.parse(URI.parse(url).query.not_nil!)["continuation"]
|
|
|
|
continuation = HTTP::Params.parse(URI.parse(url).query.not_nil!)["continuation"]
|
|
|
|
|
|
|
|
|
|
|
|
wrapper = URI.unescape(wrapper)
|
|
|
|
continuation = URI.unescape(continuation)
|
|
|
|
wrapper = Base64.decode(wrapper)
|
|
|
|
data = IO::Memory.new(Base64.decode(continuation))
|
|
|
|
|
|
|
|
|
|
|
|
# 0xe2 0xa9 0x85 0xb2 0x02
|
|
|
|
# 0xe2 0xa9 0x85 0xb2 0x02
|
|
|
|
wrapper += 5
|
|
|
|
data.pos += 5
|
|
|
|
|
|
|
|
|
|
|
|
continuation_size = read_var_int(wrapper[0, 4])
|
|
|
|
continuation = Bytes.new(data.read_bytes(VarInt))
|
|
|
|
wrapper += write_var_int(continuation_size).size
|
|
|
|
data.read continuation
|
|
|
|
continuation = wrapper[0, continuation_size]
|
|
|
|
data = IO::Memory.new(continuation)
|
|
|
|
|
|
|
|
|
|
|
|
# 0x12
|
|
|
|
data.read_byte # => 0x12
|
|
|
|
continuation += 1
|
|
|
|
ucid = Bytes.new(data.read_bytes(VarInt))
|
|
|
|
ucid_size = continuation[0]
|
|
|
|
data.read ucid
|
|
|
|
continuation += 1
|
|
|
|
|
|
|
|
ucid = continuation[0, ucid_size]
|
|
|
|
data.read_byte # => 0x1a
|
|
|
|
continuation += ucid_size
|
|
|
|
inner_continuation = Bytes.new(data.read_bytes(VarInt))
|
|
|
|
|
|
|
|
data.read inner_continuation
|
|
|
|
# 0x1a
|
|
|
|
|
|
|
|
continuation += 1
|
|
|
|
continuation = String.new(inner_continuation)
|
|
|
|
meta_size = read_var_int(continuation[0, 4])
|
|
|
|
continuation = URI.unescape(continuation)
|
|
|
|
continuation += write_var_int(meta_size).size
|
|
|
|
data = IO::Memory.new(Base64.decode(continuation))
|
|
|
|
meta = continuation[0, meta_size]
|
|
|
|
|
|
|
|
continuation += meta_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta = String.new(meta)
|
|
|
|
|
|
|
|
meta = URI.unescape(meta)
|
|
|
|
|
|
|
|
meta = Base64.decode(meta)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 0x12 0x09 playlists
|
|
|
|
# 0x12 0x09 playlists
|
|
|
|
meta += 11
|
|
|
|
data.pos += 11
|
|
|
|
|
|
|
|
|
|
|
|
until meta[0] == 0x7a
|
|
|
|
until data.peek[0] == 0x7a
|
|
|
|
tag = read_var_int(meta[0, 4])
|
|
|
|
key = data.read_bytes(VarInt)
|
|
|
|
meta += write_var_int(tag).size
|
|
|
|
value = data.read_bytes(VarInt)
|
|
|
|
value = meta[0]
|
|
|
|
|
|
|
|
meta += 1
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 0x7a
|
|
|
|
data.pos += 1 # => 0x7a
|
|
|
|
meta += 1
|
|
|
|
cursor = Bytes.new(data.read_bytes(VarInt))
|
|
|
|
cursor_size = meta[0]
|
|
|
|
data.read cursor
|
|
|
|
meta += 1
|
|
|
|
|
|
|
|
cursor = meta[0, cursor_size]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor = String.new(cursor)
|
|
|
|
cursor = String.new(cursor)
|
|
|
|
|
|
|
|
|
|
|
|
if !auto_generated
|
|
|
|
if !auto_generated
|
|
|
@ -874,20 +869,26 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
def produce_channel_community_continuation(ucid, cursor)
|
|
|
|
def produce_channel_community_continuation(ucid, cursor)
|
|
|
|
cursor = URI.escape(cursor)
|
|
|
|
cursor = URI.escape(cursor)
|
|
|
|
continuation = IO::Memory.new
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation.write(Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02])
|
|
|
|
data = IO::Memory.new
|
|
|
|
continuation.write(write_var_int(3 + ucid.size + write_var_int(cursor.size).size + cursor.size))
|
|
|
|
|
|
|
|
|
|
|
|
data.write_byte 0x12
|
|
|
|
|
|
|
|
VarInt.to_io(data, ucid.bytesize)
|
|
|
|
|
|
|
|
data.print ucid
|
|
|
|
|
|
|
|
|
|
|
|
continuation.write(Bytes[0x12, ucid.size])
|
|
|
|
data.write_byte 0x1a
|
|
|
|
continuation.print(ucid)
|
|
|
|
VarInt.to_io(data, cursor.bytesize)
|
|
|
|
|
|
|
|
data.print cursor
|
|
|
|
|
|
|
|
|
|
|
|
continuation.write(Bytes[0x1a])
|
|
|
|
data.rewind
|
|
|
|
continuation.write(write_var_int(cursor.size))
|
|
|
|
|
|
|
|
continuation.print(cursor)
|
|
|
|
|
|
|
|
continuation.rewind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation = Base64.urlsafe_encode(continuation.to_slice)
|
|
|
|
buffer = IO::Memory.new
|
|
|
|
|
|
|
|
buffer.write Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02]
|
|
|
|
|
|
|
|
VarInt.to_io(buffer, data.size)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IO.copy data, buffer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continuation = Base64.urlsafe_encode(buffer)
|
|
|
|
continuation = URI.escape(continuation)
|
|
|
|
continuation = URI.escape(continuation)
|
|
|
|
|
|
|
|
|
|
|
|
return continuation
|
|
|
|
return continuation
|
|
|
@ -895,28 +896,25 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
def extract_channel_community_cursor(continuation)
|
|
|
|
def extract_channel_community_cursor(continuation)
|
|
|
|
continuation = URI.unescape(continuation)
|
|
|
|
continuation = URI.unescape(continuation)
|
|
|
|
continuation = Base64.decode(continuation)
|
|
|
|
data = IO::Memory.new(Base64.decode(continuation))
|
|
|
|
|
|
|
|
|
|
|
|
# 0xe2 0xa9 0x85 0xb2 0x02
|
|
|
|
# 0xe2 0xa9 0x85 0xb2 0x02
|
|
|
|
continuation += 5
|
|
|
|
data.pos += 5
|
|
|
|
|
|
|
|
|
|
|
|
total_size = read_var_int(continuation[0, 4])
|
|
|
|
continuation = Bytes.new(data.read_bytes(VarInt))
|
|
|
|
continuation += write_var_int(total_size).size
|
|
|
|
data.read continuation
|
|
|
|
|
|
|
|
data = IO::Memory.new(continuation)
|
|
|
|
# 0x12
|
|
|
|
|
|
|
|
continuation += 1
|
|
|
|
data.read_byte # => 0x12
|
|
|
|
ucid_size = continuation[0]
|
|
|
|
ucid = Bytes.new(data.read_bytes(VarInt))
|
|
|
|
continuation += 1
|
|
|
|
data.read ucid
|
|
|
|
ucid = continuation[0, ucid_size]
|
|
|
|
|
|
|
|
continuation += ucid_size
|
|
|
|
data.read_byte # => 0x1a
|
|
|
|
|
|
|
|
until data.peek[0] == 'E'.ord
|
|
|
|
# 0x1a
|
|
|
|
data.read_byte
|
|
|
|
continuation += 1
|
|
|
|
|
|
|
|
until continuation[0] == 'E'.ord
|
|
|
|
|
|
|
|
continuation += 1
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return String.new(continuation)
|
|
|
|
return URI.unescape(data.gets_to_end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def get_about_info(ucid, locale)
|
|
|
|
def get_about_info(ucid, locale)
|
|
|
|