Dirty fix to get back the channel videos
This commit is contained in:
parent
46a63e6150
commit
9da1827e95
@ -5,13 +5,13 @@ CONFIG = Config.from_yaml(File.open("config/config.example.yml"))
|
|||||||
Spectator.describe "Helper" do
|
Spectator.describe "Helper" do
|
||||||
describe "#produce_channel_videos_url" do
|
describe "#produce_channel_videos_url" do
|
||||||
it "correctly produces url for requesting page `x` of a channel's videos" do
|
it "correctly produces url for requesting page `x` of a channel's videos" do
|
||||||
expect(produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw")).to eq("/browse_ajax?continuation=4qmFsgI8EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4&gl=US&hl=en")
|
# expect(produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw")).to eq("/browse_ajax?continuation=4qmFsgI8EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4&gl=US&hl=en")
|
||||||
|
#
|
||||||
|
# expect(produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", sort_by: "popular")).to eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4R0FFPQ%3D%3D&gl=US&hl=en")
|
||||||
|
|
||||||
expect(produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", sort_by: "popular")).to eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4R0FFPQ%3D%3D&gl=US&hl=en")
|
# expect(produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", page: 20)).to eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUE9PQ%3D%3D&gl=US&hl=en")
|
||||||
|
|
||||||
expect(produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", page: 20)).to eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUE9PQ%3D%3D&gl=US&hl=en")
|
# expect(produce_channel_videos_url(ucid: "UC-9-kyTW8ZkZNDHQJ6FgpwQ", page: 20, sort_by: "popular")).to eq("/browse_ajax?continuation=4qmFsgJAEhhVQy05LWt5VFc4WmtaTkRIUUo2Rmdwd1EaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUJnQg%3D%3D&gl=US&hl=en")
|
||||||
|
|
||||||
expect(produce_channel_videos_url(ucid: "UC-9-kyTW8ZkZNDHQJ6FgpwQ", page: 20, sort_by: "popular")).to eq("/browse_ajax?continuation=4qmFsgJAEhhVQy05LWt5VFc4WmtaTkRIUUo2Rmdwd1EaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUJnQg%3D%3D&gl=US&hl=en")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,53 +1,48 @@
|
|||||||
def produce_channel_videos_continuation(ucid, page = 1, auto_generated = nil, sort_by = "newest", v2 = false)
|
def produce_channel_videos_continuation(ucid, page = 1, auto_generated = nil, sort_by = "newest", v2 = false)
|
||||||
object = {
|
object_inner_2 = {
|
||||||
"80226972:embedded" => {
|
"2:0:embedded" => {
|
||||||
"2:string" => ucid,
|
"1:0:varint" => 0_i64,
|
||||||
"3:base64" => {
|
},
|
||||||
"2:string" => "videos",
|
"5:varint" => 50_i64,
|
||||||
"6:varint" => 2_i64,
|
"6:varint" => 1_i64,
|
||||||
"7:varint" => 1_i64,
|
"7:varint" => (page * 30).to_i64,
|
||||||
"12:varint" => 1_i64,
|
"9:varint" => 1_i64,
|
||||||
"13:string" => "",
|
"10:varint" => 0_i64,
|
||||||
"23:varint" => 0_i64,
|
}
|
||||||
|
|
||||||
|
object_inner_2_encoded = object_inner_2
|
||||||
|
.try { |i| Protodec::Any.cast_json(i) }
|
||||||
|
.try { |i| Protodec::Any.from_json(i) }
|
||||||
|
.try { |i| Base64.urlsafe_encode(i) }
|
||||||
|
.try { |i| URI.encode_www_form(i) }
|
||||||
|
|
||||||
|
object_inner_1 = {
|
||||||
|
"110:embedded" => {
|
||||||
|
"3:embedded" => {
|
||||||
|
"15:embedded" => {
|
||||||
|
"1:embedded" => {
|
||||||
|
"1:string" => object_inner_2_encoded,
|
||||||
|
"2:string" => "00000000-0000-0000-0000-000000000000",
|
||||||
|
},
|
||||||
|
"3:varint" => 1_i64,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if !v2
|
object_inner_1_encoded = object_inner_1
|
||||||
if auto_generated
|
.try { |i| Protodec::Any.cast_json(i) }
|
||||||
seed = Time.unix(1525757349)
|
.try { |i| Protodec::Any.from_json(i) }
|
||||||
until seed >= Time.utc
|
.try { |i| Base64.urlsafe_encode(i) }
|
||||||
seed += 1.month
|
.try { |i| URI.encode_www_form(i) }
|
||||||
end
|
|
||||||
timestamp = seed - (page - 1).months
|
|
||||||
|
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0x36_i64
|
object = {
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = "#{timestamp.to_unix}"
|
"80226972:embedded" => {
|
||||||
else
|
"2:string" => ucid,
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0_i64
|
"3:string" => object_inner_1_encoded,
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = "#{page}"
|
"35:string" => "browse-feed#{ucid}videos102",
|
||||||
end
|
},
|
||||||
else
|
}
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0_i64
|
|
||||||
|
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["61:string"] = Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json({
|
|
||||||
"1:string" => Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json({
|
|
||||||
"1:varint" => 30_i64 * (page - 1),
|
|
||||||
}))),
|
|
||||||
})))
|
|
||||||
end
|
|
||||||
|
|
||||||
case sort_by
|
|
||||||
when "newest"
|
|
||||||
when "popular"
|
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 0x01_i64
|
|
||||||
when "oldest"
|
|
||||||
object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 0x02_i64
|
|
||||||
else nil # Ignore
|
|
||||||
end
|
|
||||||
|
|
||||||
object["80226972:embedded"]["3:string"] = Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json(object["80226972:embedded"]["3:base64"])))
|
|
||||||
object["80226972:embedded"].delete("3:base64")
|
|
||||||
|
|
||||||
continuation = object.try { |i| Protodec::Any.cast_json(i) }
|
continuation = object.try { |i| Protodec::Any.cast_json(i) }
|
||||||
.try { |i| Protodec::Any.from_json(i) }
|
.try { |i| Protodec::Any.from_json(i) }
|
||||||
@ -67,10 +62,11 @@ end
|
|||||||
def get_60_videos(ucid, author, page, auto_generated, sort_by = "newest")
|
def get_60_videos(ucid, author, page, auto_generated, sort_by = "newest")
|
||||||
videos = [] of SearchVideo
|
videos = [] of SearchVideo
|
||||||
|
|
||||||
2.times do |i|
|
# 2.times do |i|
|
||||||
initial_data = get_channel_videos_response(ucid, page * 2 + (i - 1), auto_generated: auto_generated, sort_by: sort_by)
|
# initial_data = get_channel_videos_response(ucid, page * 2 + (i - 1), auto_generated: auto_generated, sort_by: sort_by)
|
||||||
videos.concat extract_videos(initial_data, author, ucid)
|
initial_data = get_channel_videos_response(ucid, 1, auto_generated: auto_generated, sort_by: sort_by)
|
||||||
end
|
videos = extract_videos(initial_data, author, ucid)
|
||||||
|
# end
|
||||||
|
|
||||||
return videos.size, videos
|
return videos.size, videos
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user