Fix produce_playlist_url

This commit is contained in:
Omar Roth 2018-08-14 17:00:35 -05:00
parent 7dfb301858
commit c5bd5e6c6d

View file

@ -116,33 +116,34 @@ def login_req(login_form, f_req)
return HTTP::Params.encode(data) return HTTP::Params.encode(data)
end end
def produce_playlist_url(ucid, index) def produce_playlist_url(id, index)
ucid = ucid.lchop("UC") if id.starts_with? "UC"
ucid = "VLUU" + ucid id = "UU" + id.lchop("UC")
end
ucid = "VL" + id
continuation = write_var_int(index) continuation = [0x08_u8] + write_var_int(index)
continuation.unshift(0x08_u8)
slice = continuation.to_unsafe.to_slice(continuation.size) slice = continuation.to_unsafe.to_slice(continuation.size)
slice = Base64.urlsafe_encode(slice, false)
continuation = Base64.urlsafe_encode(slice, false) # Inner Base64
continuation = "PT:" + continuation continuation = "PT:" + slice
continuation = continuation.bytes continuation = [0x7a_u8, continuation.bytes.size.to_u8] + continuation.bytes
continuation.unshift(0x7a_u8, continuation.size.to_u8)
slice = continuation.to_unsafe.to_slice(continuation.size) slice = continuation.to_unsafe.to_slice(continuation.size)
continuation = Base64.urlsafe_encode(slice) slice = Base64.urlsafe_encode(slice)
continuation = URI.escape(continuation) slice = URI.escape(slice)
continuation = continuation.bytes
continuation.unshift(continuation.size.to_u8)
continuation.unshift(ucid.size.to_u8) # Outer Base64
continuation = [0x1a.to_u8, slice.bytes.size.to_u8] + slice.bytes
continuation = ucid.bytes + continuation continuation = ucid.bytes + continuation
continuation.unshift(0x12.to_u8, ucid.size.to_u8) continuation = [0x12_u8, ucid.size.to_u8] + continuation
continuation.unshift(0xe2_u8, 0xa9_u8, 0x85_u8, 0xb2_u8, 2_u8, continuation.size.to_u8) continuation = [0xe2_u8, 0xa9_u8, 0x85_u8, 0xb2_u8, 2_u8, continuation.size.to_u8] + continuation
# Wrap bytes
slice = continuation.to_unsafe.to_slice(continuation.size) slice = continuation.to_unsafe.to_slice(continuation.size)
continuation = Base64.urlsafe_encode(slice) slice = Base64.urlsafe_encode(slice)
continuation = URI.escape(continuation) slice = URI.escape(slice)
continuation = slice
url = "/browse_ajax?action_continuation=1&continuation=#{continuation}" url = "/browse_ajax?action_continuation=1&continuation=#{continuation}"