From 2ebfaf76f29f52293611e966ea1a82736ae7ea93 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 27 Oct 2019 13:50:42 -0400 Subject: [PATCH] Refactor continuation token handling --- shard.yml | 3 + spec/helpers_spec.cr | 43 +++--- src/invidious.cr | 1 + src/invidious/channels.cr | 266 +++++++++++-------------------------- src/invidious/comments.cr | 175 +++++++++--------------- src/invidious/playlists.cr | 56 +++----- src/invidious/search.cr | 160 +++++++++------------- 7 files changed, 256 insertions(+), 448 deletions(-) diff --git a/shard.yml b/shard.yml index 04c20893..3bad9b5e 100644 --- a/shard.yml +++ b/shard.yml @@ -21,6 +21,9 @@ dependencies: pool: github: ysbaddaden/pool version: ~> 0.2.3 + protodec: + github: omarroth/protodec + version: ~> 0.1.2 crystal: 0.31.1 diff --git a/spec/helpers_spec.cr b/spec/helpers_spec.cr index dd12a9e6..7ede7e7a 100644 --- a/spec/helpers_spec.cr +++ b/spec/helpers_spec.cr @@ -1,6 +1,7 @@ require "kemal" require "openssl/hmac" require "pg" +require "protodec/utils" require "spec" require "yaml" require "../src/invidious/helpers/*" @@ -15,9 +16,9 @@ describe "Helper" do it "correctly produces url for requesting page `x` of a channel's videos" do produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw").should eq("/browse_ajax?continuation=4qmFsgI8EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4&gl=US&hl=en") - produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJCEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJkVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4R0FFJTNE&gl=US&hl=en") + produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0V4R0FFPQ%3D%3D&gl=US&hl=en") - produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", page: 20).should eq("/browse_ajax?continuation=4qmFsgJEEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaKEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUElM0QlM0Q%3D&gl=US&hl=en") + produce_channel_videos_url(ucid: "UCXuqSBlHAE6Xw-yeJA0Tunw", page: 20).should eq("/browse_ajax?continuation=4qmFsgJAEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUE9PQ%3D%3D&gl=US&hl=en") produce_channel_videos_url(ucid: "UC-9-kyTW8ZkZNDHQJ6FgpwQ", page: 20, sort_by: "popular").should eq("/browse_ajax?continuation=4qmFsgJAEhhVQy05LWt5VFc4WmtaTkRIUUo2Rmdwd1EaJEVnWjJhV1JsYjNNd0FqZ0JZQUZxQUxnQkFDQUFlZ0l5TUJnQg%3D%3D&gl=US&hl=en") end @@ -27,13 +28,13 @@ describe "Helper" do it "correctly produces token for searching a specific channel" do produce_channel_search_url("UCXuqSBlHAE6Xw-yeJA0Tunw", "", 100).should eq("/browse_ajax?continuation=4qmFsgI-EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWnpaV0Z5WTJnd0FqZ0JZQUZxQUxnQkFIb0RNVEF3WgA%3D&gl=US&hl=en") - produce_channel_search_url("UCXuqSBlHAE6Xw-yeJA0Tunw", "По ожиशुपतिरपि子而時ஸ்றீனி", 0).should eq("/browse_ajax?continuation=4qmFsgKAARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GiRFZ1p6WldGeVkyZ3dBamdCWUFGcUFMZ0JBSG9CTUElM0QlM0RaPtCf0L4g0L7QttC44KS24KWB4KSq4KSk4KS_4KSw4KSq4KS_5a2Q6ICM5pmC4K644K-N4K6x4K-A4K6p4K6_&gl=US&hl=en") + produce_channel_search_url("UCXuqSBlHAE6Xw-yeJA0Tunw", "По ожиशुपतिरपि子而時ஸ்றீனி", 0).should eq("/browse_ajax?continuation=4qmFsgJ8EhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWnpaV0Z5WTJnd0FqZ0JZQUZxQUxnQkFIb0JNQT09Wj7Qn9C-INC-0LbQuOCktuClgeCkquCkpOCkv-CksOCkquCkv-WtkOiAjOaZguCuuOCvjeCuseCvgOCuqeCuvw%3D%3D&gl=US&hl=en") end end describe "#produce_channel_playlists_url" do it "correctly produces a /browse_ajax URL with the given UCID and cursor" do - produce_channel_playlists_url("UCCj956IF62FbT7Gouszaj9w", "AIOkY9EQpi_gyn1_QrFuZ1reN81_MMmI1YmlBblw8j7JHItEFG5h7qcJTNd4W9x5Quk_CVZ028gW").should eq("/browse_ajax?continuation=4qmFsgLRARIYVUNDajk1NklGNjJGYlQ3R291c3phajl3GrQBRWdsd2JHRjViR2x6ZEhNWUF5QUJNQUk0QVdBQmFnQjZabEZWYkZCaE1XczFVbFpHZDJGV09XNWxWelI0V0RGR2VWSnVWbUZOV0Vwc1ZHcG5lRmd3TVU1aVZXdDRWMWN4YzFGdFNuTmtlbWh4VGpCd1NWTllVa1pTYTJNeFlVUmtlRmt3Y0ZWVWJWRXdWbnBzTkU1V1JqRmhNVGxFVm14dmQwMXFhRzVXZDdnQkFBJTNEJTNE&gl=US&hl=en") + produce_channel_playlists_url("UCCj956IF62FbT7Gouszaj9w", "AIOkY9EQpi_gyn1_QrFuZ1reN81_MMmI1YmlBblw8j7JHItEFG5h7qcJTNd4W9x5Quk_CVZ028gW").should eq("/browse_ajax?continuation=4qmFsgLJARIYVUNDajk1NklGNjJGYlQ3R291c3phajl3GqwBRWdod2JHRjViR2x6ZERBQ09BRmdBV29BdUFFQWVtWlJWV3hRWVRGck5WSldSbmRoVmpsdVpWYzBlRmd4Um5sU2JsWmhUVmhLYkZScVozaFlNREZPWWxWcmVGZFhNWE5SYlVwelpIcG9jVTR3Y0VsVFdGSkdVbXRqTVdGRVpIaFpNSEJWVkcxUk1GWjZiRFJPVmtZeFlURTVSRlpzYjNkTmFtaHVWbmNnQVJnRA%3D%3D&gl=US&hl=en") end end @@ -45,15 +46,15 @@ describe "Helper" do describe "#produce_playlist_url" do it "correctly produces url for requesting index `x` of a playlist" do - produce_playlist_url("UUCla9fZca4I7KagBtgRGnOw", 0).should eq("/browse_ajax?continuation=4qmFsgIsEhpWTFVVQ2xhOWZaY2E0STdLYWdCdGdSR25PdxoOZWdaUVZEcERRVUUlM0Q%3D&gl=US&hl=en") + produce_playlist_url("UUCla9fZca4I7KagBtgRGnOw", 0).should eq("/browse_ajax?continuation=4qmFsgIqEhpWTFVVQ2xhOWZaY2E0STdLYWdCdGdSR25PdxoMZWdaUVZEcERRVUU9&gl=US&hl=en") - produce_playlist_url("UCCla9fZca4I7KagBtgRGnOw", 0).should eq("/browse_ajax?continuation=4qmFsgIsEhpWTFVVQ2xhOWZaY2E0STdLYWdCdGdSR25PdxoOZWdaUVZEcERRVUUlM0Q%3D&gl=US&hl=en") + produce_playlist_url("UCCla9fZca4I7KagBtgRGnOw", 0).should eq("/browse_ajax?continuation=4qmFsgIqEhpWTFVVQ2xhOWZaY2E0STdLYWdCdGdSR25PdxoMZWdaUVZEcERRVUU9&gl=US&hl=en") - produce_playlist_url("PLt5AfwLFPxWLNVixpe1w3fi6lE2OTq0ET", 0).should eq("/browse_ajax?continuation=4qmFsgI2EiRWTFBMdDVBZndMRlB4V0xOVml4cGUxdzNmaTZsRTJPVHEwRVQaDmVnWlFWRHBEUVVFJTNE&gl=US&hl=en") + produce_playlist_url("PLt5AfwLFPxWLNVixpe1w3fi6lE2OTq0ET", 0).should eq("/browse_ajax?continuation=4qmFsgI0EiRWTFBMdDVBZndMRlB4V0xOVml4cGUxdzNmaTZsRTJPVHEwRVQaDGVnWlFWRHBEUVVFPQ%3D%3D&gl=US&hl=en") produce_playlist_url("PLt5AfwLFPxWLNVixpe1w3fi6lE2OTq0ET", 10000).should eq("/browse_ajax?continuation=4qmFsgI0EiRWTFBMdDVBZndMRlB4V0xOVml4cGUxdzNmaTZsRTJPVHEwRVQaDGVnZFFWRHBEU2tKUA%3D%3D&gl=US&hl=en") - produce_playlist_url("PL55713C70BA91BD6E", 0).should eq("/browse_ajax?continuation=4qmFsgImEhRWTFBMNTU3MTNDNzBCQTkxQkQ2RRoOZWdaUVZEcERRVUUlM0Q%3D&gl=US&hl=en") + produce_playlist_url("PL55713C70BA91BD6E", 0).should eq("/browse_ajax?continuation=4qmFsgIkEhRWTFBMNTU3MTNDNzBCQTkxQkQ2RRoMZWdaUVZEcERRVUU9&gl=US&hl=en") produce_playlist_url("PL55713C70BA91BD6E", 10000).should eq("/browse_ajax?continuation=4qmFsgIkEhRWTFBMNTU3MTNDNzBCQTkxQkQ2RRoMZWdkUVZEcERTa0pQ&gl=US&hl=en") end @@ -73,15 +74,23 @@ describe "Helper" do end end + describe "#extract_comment_cursor" do + it "correctly extracts a comment cursor from a given continuation" do + extract_comment_cursor("EiYSC2tKUVA3a2l3NUZrwAEByAEB4AEBogINKP___________wFAABgGMpwFCoYFQURTSl9pM1RqN1VlZ3dBd1daZkk4TmNiZ0djLVp0NFZEaW1BUGZwWHlPNDhuYUFxa3BsOXZYTk41OWpGXzNGRkVZeVpJOHRGWWpla0w1Z2ktcjhLdGFhcmduMDFxTUpsQ19QN2NaLWU5VGxxbTgzeUN6QVFHSUVtMGlMbUs5ZmVNOUVmNVo2S24xclpPRmlOdkxJS3JIUlJhWS10dkFNdzBDb0R3UWxiSXdpNDAzNkNCQ0ZXY2syemh1VHBsdEVUa2RmRHVrYVdkNnR1X1F4dkdnMGRkeEMydnNuVnlsQ1lJSUliWjAwMk1UTmpsbWJ5ejNKeGVybHJoa1drN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u9aso8LwO1UIfkduh1I5LcCZYIO-wusU1rsy1eyzD-gCAN") + end + end + describe "#produce_comment_continuation" do it "correctly produces a continuation token for comments" do produce_comment_continuation("_cE8xSu6swE", "ADSJ_i2qvJeFtL0htmS5_K5Ctj3eGFVBMWL9Wd42o3kmUL6_mAzdLp85-liQZL0mYr_16BhaggUqX652Sv9JqV6VXinShSP-ZT6rL4NolPBaPXVtJsO5_rA_qE3GubAuLFw9uzIIXU2-HnpXbdgPLWTFavfX206hqWmmpHwUOrmxQV_OX6tYkM3ux3rPAKCDrT8eWL7MU3bLiNcnbgkW8o0h8KYLL_8BPa8LcHbTv8pAoNkjerlX1x7K4pqxaXPoyz89qNlnh6rRx6AXgAzzoHH1dmcyQ8CIBeOHg-m4i8ZxdX4dP88XWrIFg-jJGhpGP8JUMDgZgavxVx225hUEYZMyrLGler5em4FgbG62YWC51moLDLeYEA").should eq("EiYSC19jRTh4U3U2c3dFwAEByAEB4AEBogINKP___________wFAABgGMowDCvYCQURTSl9pMnF2SmVGdEwwaHRtUzVfSzVDdGozZUdGVkJNV0w5V2Q0Mm8za21VTDZfbUF6ZExwODUtbGlRWkwwbVlyXzE2QmhhZ2dVcVg2NTJTdjlKcVY2VlhpblNoU1AtWlQ2ckw0Tm9sUEJhUFhWdEpzTzVfckFfcUUzR3ViQXVMRnc5dXpJSVhVMi1IbnBYYmRnUExXVEZhdmZYMjA2aHFXbW1wSHdVT3JteFFWX09YNnRZa00zdXgzclBBS0NEclQ4ZVdMN01VM2JMaU5jbmJna1c4bzBoOEtZTExfOEJQYThMY0hiVHY4cEFvTmtqZXJsWDF4N0s0cHF4YVhQb3l6ODlxTmxuaDZyUng2QVhnQXp6b0hIMWRtY3lROENJQmVPSGctbTRpOFp4ZFg0ZFA4OFhXcklGZy1qSkdocEdQOEpVTURnWmdhdnhWeDIyNWhVRVlaTXlyTEdsZXI1ZW00RmdiRzYyWVdDNTFtb0xETGVZRUEiDyILX2NFOHhTdTZzd0UwACgU") produce_comment_continuation("_cE8xSu6swE", "ADSJ_i1yz21HI4xrtsYXVC-2_kfZ6kx1yjYQumXAAxqH3CAd7ZxKxfLdZS1__fqhCtOASRbbpSBGH_tH1J96Dxux-Qfjk-lUbupMqv08Q3aHzGu7p70VoUMHhI2-GoJpnbpmcOxkGzeIuenRS_ym2Y8fkDowhqLPFgsS0n4djnZ2UmC17F3Ch3N1S1UYf1ZVOc991qOC1iW9kJDzyvRQTWCPsJUPneSaAKW-Rr97pdesOkR4i8cNvHZRnQKe2HEfsvlJOb2C3lF1dJBfJeNfnQYeh5hv6_fZN7bt3-JL1Xk3Qc9NXNxmmbDpwAC_yFR8dthFfUJdyIO9Nu1D79MLYeR-H5HxqUJokkJiGIz4lTE_CXXbhAI").should eq("EiYSC19jRTh4U3U2c3dFwAEByAEB4AEBogINKP___________wFAABgGMokDCvMCQURTSl9pMXl6MjFISTR4cnRzWVhWQy0yX2tmWjZreDF5allRdW1YQUF4cUgzQ0FkN1p4S3hmTGRaUzFfX2ZxaEN0T0FTUmJicFNCR0hfdEgxSjk2RHh1eC1RZmprLWxVYnVwTXF2MDhRM2FIekd1N3A3MFZvVU1IaEkyLUdvSnBuYnBtY094a0d6ZUl1ZW5SU195bTJZOGZrRG93aHFMUEZnc1MwbjRkam5aMlVtQzE3RjNDaDNOMVMxVVlmMVpWT2M5OTFxT0MxaVc5a0pEenl2UlFUV0NQc0pVUG5lU2FBS1ctUnI5N3BkZXNPa1I0aThjTnZIWlJuUUtlMkhFZnN2bEpPYjJDM2xGMWRKQmZKZU5mblFZZWg1aHY2X2ZaTjdidDMtSkwxWGszUWM5TlhOeG1tYkRwd0FDX3lGUjhkdGhGZlVKZHlJTzlOdTFENzlNTFllUi1INUh4cVVKb2trSmlHSXo0bFRFX0NYWGJoQUkiDyILX2NFOHhTdTZzd0UwACgU") - produce_comment_continuation("29-q7YnyUmY", "").should eq("EiYSCzI5LXE3WW55VW1ZwAEByAEB4AEBogINKP___________wFAABgGMhMiDyILMjktcTdZbnlVbVkwAHgC") + produce_comment_continuation("29-q7YnyUmY", "").should eq("EiYSCzI5LXE3WW55VW1ZwAEByAEB4AEBogINKP___________wFAABgGMhUKACIPIgsyOS1xN1lueVVtWTAAKBQ%3D") - produce_comment_continuation("CvFH_6DNRCY", "").should eq("EiYSC0N2RkhfNkROUkNZwAEByAEB4AEBogINKP___________wFAABgGMhMiDyILQ3ZGSF82RE5SQ1kwAHgC") + produce_comment_continuation("CvFH_6DNRCY", "").should eq("EiYSC0N2RkhfNkROUkNZwAEByAEB4AEBogINKP___________wFAABgGMhUKACIPIgtDdkZIXzZETlJDWTAAKBQ%3D") end end @@ -98,20 +107,20 @@ describe "Helper" do describe "#produce_channel_community_continuation" do it "correctly produces a continuation token for a channel community" do produce_channel_community_continuation("UCCj956IF62FbT7Gouszaj9w", "Egljb21tdW5pdHm4").should eq("4qmFsgIsEhhVQ0NqOTU2SUY2MkZiVDdHb3VzemFqOXcaEEVnbGpiMjF0ZFc1cGRIbTQ%3D") - produce_channel_community_continuation("UCCj956IF62FbT7Gouszaj9w", "Egljb21tdW5pdHm4AQCqAyQaIBIaVWd3cE9NQmVwWEdjclhsUHg2WjRBYUFCQ1FIZGgDKAA%3D").should eq("4qmFsgJoEhhVQ0NqOTU2SUY2MkZiVDdHb3VzemFqOXcaTEVnbGpiMjF0ZFc1cGRIbTRBUUNxQXlRYUlCSWFWV2QzY0U5TlFtVndXRWRqY2xoc1VIZzJXalJCWVVGQ1ExRklaR2dES0FBJTI1M0Q%3D") + produce_channel_community_continuation("UCCj956IF62FbT7Gouszaj9w", "Egljb21tdW5pdHm4AQCqAyQaIBIaVWd3cE9NQmVwWEdjclhsUHg2WjRBYUFCQ1FIZGgDKAA%3D").should eq("4qmFsgJmEhhVQ0NqOTU2SUY2MkZiVDdHb3VzemFqOXcaSkVnbGpiMjF0ZFc1cGRIbTRBUUNxQXlRYUlCSWFWV2QzY0U5TlFtVndXRWRqY2xoc1VIZzJXalJCWVVGQ1ExRklaR2dES0FBJTNE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extracts a community cursor from a given continuation" do - extract_channel_community_cursor("4qmFsgIsEhhVQ0NqOTU2SUY2MkZiVDdHb3VzemFqOXcaEEVnbGpiMjF0ZFc1cGRIbTQ%3D").should eq("Egljb21tdW5pdHm4") - extract_channel_community_cursor("4qmFsgJoEhhVQ0NqOTU2SUY2MkZiVDdHb3VzemFqOXcaTEVnbGpiMjF0ZFc1cGRIbTRBUUNxQXlRYUlCSWFWV2QzY0U5TlFtVndXRWRqY2xoc1VIZzJXalJCWVVGQ1ExRklaR2dES0FBJTI1M0Q%3D").should eq("Egljb21tdW5pdHm4AQCqAyQaIBIaVWd3cE9NQmVwWEdjclhsUHg2WjRBYUFCQ1FIZGgDKAA%3D") + extract_channel_community_cursor("4qmFsgIsEhhVQ0NqOTU2SUY2MkZiVDdHb3VzemFqOXcaEEVnbGpiMjF0ZFc1cGRIbTQ%3D").should eq("Egljb21tdW5pdHk=") + extract_channel_community_cursor("4qmFsgJoEhhVQ0NqOTU2SUY2MkZiVDdHb3VzemFqOXcaTEVnbGpiMjF0ZFc1cGRIbTRBUUNxQXlRYUlCSWFWV2QzY0U5TlFtVndXRWRqY2xoc1VIZzJXalJCWVVGQ1ExRklaR2dES0FBJTI1M0Q%3D").should eq("Egljb21tdW5pdHm4AQCqAyYaIhIcVWd3cE9NQmVwWEdjclhsUHg2WjRBYUFCQ1E9PUhkaAMoAA==") - extract_channel_community_cursor("4qmFsgJoEhhVQy1sSEpaUjNHcXhtMjRfVmRfQUo1WXcaTEVnbGpiMjF0ZFc1cGRIbTRBUUNxQXlRYUlCSWFWV2Q1UlRJMk5XMXJVa2syY0U5dVMyMW5iRFJCWVVGQ1ExRklaR2dES0FBJTI1M0Q%3D").should eq("Egljb21tdW5pdHm4AQCqAyQaIBIaVWd5RTI2NW1rUkk2cE9uS21nbDRBYUFCQ1FIZGgDKAA%3D") - extract_channel_community_cursor("4qmFsgKZFBIYVUMtbEhKWlIzR3F4bTI0X1ZkX0FKNVl3GvwTRWdsamIyMXRkVz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2QwNW1VRXd5YUZCZlEwWjFSbEUzY0doRk5ISkZZMWxTTWs5d2RXRnhiRzFrYjBVMmIxWkJaRzkyU2xneFZWOXNiMDVWWkUxRFJ6QjBjWGhpVjBVMldYY3pTUzF4UVcxa1RuZEJRVGRvWVZFNGNsSTBaVUl0UmxacVdETnJXazVLY21aRk9HVndRbWxqUjB0blRFZEZVR3N6YzJOclkwSTNlVlZZVEdkcE1YQkdiMHAyZVU1aGRVZFdVblJQYVhaQlZtdHZSa0UzTFU1Sk1XaFJRMUpMV2kxSWJ6WkxjWEkxZGtSTWJsOVdUa0ZFVmpKZmMwUlFWV3gwUTJ0TFRsbDJaM2gxZFVOSVkzbEVORUpRZVUxMVREQnpOMVowWDI1MWRrVmlUMU54TkRkUk5rVjViMEpRTUZGNmR6RlJSR2RxY1U1eVgwNTBjMDkxWm14R2NUVjBlRkJGT1dGVmFXeFJTMEZYYldwQlVVbHNOVmgwZERZdGFFRlViMWxmUjFWc1EycG1WVkJQV0hkcFVRPT0aIhIcVWd5RTI2NW1rUkk2cE9uS21nbDRBYUFCQ1E9PUhkaAMoYw==") end end diff --git a/src/invidious.cr b/src/invidious.cr index 58bc35f8..b213eb87 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -24,6 +24,7 @@ require "sqlite3" require "xml" require "yaml" require "zip" +require "protodec/utils" require "./invidious/helpers/*" require "./invidious/*" diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index c79be352..4cf322b0 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -432,188 +432,108 @@ def fetch_channel_playlists(ucid, author, auto_generated, continuation, sort_by) end def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = "newest") + object = { + "80226972:embedded" => { + "2:string" => ucid, + "3:base64" => { + "2:string" => "videos", + "6:varint": 2_i64, + "7:varint": 1_i64, + "12:varint": 1_i64, + "13:string": "", + "23:varint": 0_i64, + }, + }, + } + if auto_generated seed = Time.unix(1525757349) - until seed >= Time.utc seed += 1.month end timestamp = seed - (page - 1).months - page = "#{timestamp.to_unix}" - switch = 0x36 + object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0x36_i64 + object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = "#{timestamp.to_unix}" else - page = "#{page}" - switch = 0x00 + object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0_i64 + object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = "#{page}" end - data = IO::Memory.new - data.write_byte 0x12 - data.write_byte 0x06 - data.print "videos" - - data.write Bytes[0x30, 0x02] - data.write Bytes[0x38, 0x01] - data.write Bytes[0x60, 0x01] - data.write Bytes[0x6a, 0x00] - data.write Bytes[0xb8, 0x01, 0x00] - - data.write Bytes[0x20, switch] - data.write_byte 0x7a - VarInt.to_io(data, page.bytesize) - data.print page - case sort_by when "newest" - # Empty tags can be omitted - # data.write(Bytes[0x18,0x00]) when "popular" - data.write Bytes[0x18, 0x01] + object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 0x01_i64 when "oldest" - data.write Bytes[0x18, 0x02] + object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 0x02_i64 end - data = Base64.urlsafe_encode(data) - cursor = URI.encode_www_form(data) + 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") - data = IO::Memory.new + continuation = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } + .try { |i| URI.encode_www_form(i) } - data.write_byte 0x12 - VarInt.to_io(data, ucid.bytesize) - data.print ucid - - data.write_byte 0x1a - VarInt.to_io(data, cursor.bytesize) - data.print cursor - - data.rewind - - buffer = IO::Memory.new - buffer.write Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02] - VarInt.to_io(buffer, data.bytesize) - - IO.copy data, buffer - - continuation = Base64.urlsafe_encode(buffer) - continuation = URI.encode_www_form(continuation) - - url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" - - return url + return "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" end def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated = false) + object = { + "80226972:embedded" => { + "2:string" => ucid, + "3:base64" => { + "2:string" => "playlist", + "6:varint": 2_i64, + "7:varint": 1_i64, + "12:varint": 1_i64, + "13:string": "", + "23:varint": 0_i64, + }, + }, + } + if !auto_generated cursor = Base64.urlsafe_encode(cursor, false) end - - data = IO::Memory.new + object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = cursor if auto_generated - data.write Bytes[0x08, 0x0a] - end - - data.write Bytes[0x12, 0x09] - data.print "playlists" - - if auto_generated - data.write Bytes[0x20, 0x32] + object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0x32_i64 else - # TODO: Look at 0x01, 0x00 + object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 1_i64 case sort when "oldest", "oldest_created" - data.write Bytes[0x18, 0x02] + object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 2_i64 when "newest", "newest_created" - data.write Bytes[0x18, 0x03] + object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 3_i64 when "last", "last_added" - data.write Bytes[0x18, 0x04] + object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 4_i64 end - - data.write Bytes[0x20, 0x01] end - data.write Bytes[0x30, 0x02] - data.write Bytes[0x38, 0x01] - data.write Bytes[0x60, 0x01] - data.write Bytes[0x6a, 0x00] + 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") - data.write_byte 0x7a - VarInt.to_io(data, cursor.bytesize) - data.print cursor + continuation = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } + .try { |i| URI.encode_www_form(i) } - data.write Bytes[0xb8, 0x01, 0x00] - - data.rewind - data = Base64.urlsafe_encode(data) - continuation = URI.encode_www_form(data) - - data = IO::Memory.new - - data.write_byte 0x12 - VarInt.to_io(data, ucid.bytesize) - data.print ucid - - data.write_byte 0x1a - VarInt.to_io(data, continuation.bytesize) - data.print continuation - - data.rewind - - buffer = IO::Memory.new - buffer.write Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02] - VarInt.to_io(buffer, data.bytesize) - - IO.copy data, buffer - - continuation = Base64.urlsafe_encode(buffer) - continuation = URI.encode_www_form(continuation) - - url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" - - return url + return "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" end def extract_channel_playlists_cursor(url, auto_generated) - continuation = HTTP::Params.parse(URI.parse(url).query.not_nil!)["continuation"] - - continuation = URI.decode_www_form(continuation) - data = IO::Memory.new(Base64.decode(continuation)) - - # 0xe2 0xa9 0x85 0xb2 0x02 - data.pos += 5 - - continuation = Bytes.new(data.read_bytes(VarInt)) - data.read continuation - data = IO::Memory.new(continuation) - - data.read_byte # => 0x12 - ucid = Bytes.new(data.read_bytes(VarInt)) - data.read ucid - - data.read_byte # => 0x1a - inner_continuation = Bytes.new(data.read_bytes(VarInt)) - data.read inner_continuation - - continuation = String.new(inner_continuation) - continuation = URI.decode_www_form(continuation) - data = IO::Memory.new(Base64.decode(continuation)) - - # 0x12 0x09 playlists - data.pos += 11 - - until data.peek[0] == 0x7a - key = data.read_bytes(VarInt) - value = data.read_bytes(VarInt) - end - - data.pos += 1 # => 0x7a - cursor = Bytes.new(data.read_bytes(VarInt)) - data.read cursor - cursor = String.new(cursor) + cursor = URI.parse(url).query_params + .try { |i| Base64.decode(i["continuation"]) } + .try { |i| IO::Memory.new(i) } + .try { |i| Protodec::Any.parse(i) } + .try { |i| i["80226972:0:embedded"]["3:1:base64"]["15:7:string"].as_s } if !auto_generated cursor = URI.decode_www_form(cursor) - cursor = Base64.decode_string(cursor) + .try { |i| Base64.decode_string(i) } end return cursor @@ -621,12 +541,9 @@ end # TODO: Add "sort_by" def fetch_channel_community(ucid, continuation, locale, config, kemal_config, format, thin_mode) - headers = HTTP::Headers.new - headers["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" - - response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=US&hl=en", headers) + response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=US&hl=en") if response.status_code == 404 - response = YT_POOL.client &.get("/user/#{ucid}/community?gl=US&hl=en", headers) + response = YT_POOL.client &.get("/user/#{ucid}/community?gl=US&hl=en") end if response.status_code == 404 @@ -648,6 +565,7 @@ def fetch_channel_community(ucid, continuation, locale, config, kemal_config, fo else continuation = produce_channel_community_continuation(ucid, continuation) + headers = HTTP::Headers.new headers["cookie"] = response.cookies.add_request_headers(headers)["cookie"] headers["content-type"] = "application/x-www-form-urlencoded" @@ -874,53 +792,31 @@ def fetch_channel_community(ucid, continuation, locale, config, kemal_config, fo end def produce_channel_community_continuation(ucid, cursor) - cursor = URI.encode_www_form(cursor) + object = { + "80226972:embedded" => { + "2:string" => ucid, + "3:string" => cursor, + }, + } - data = IO::Memory.new - - data.write_byte 0x12 - VarInt.to_io(data, ucid.bytesize) - data.print ucid - - data.write_byte 0x1a - VarInt.to_io(data, cursor.bytesize) - data.print cursor - - data.rewind - - 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.encode_www_form(continuation) + continuation = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } + .try { |i| URI.encode_www_form(i) } return continuation end def extract_channel_community_cursor(continuation) - continuation = URI.decode_www_form(continuation) - data = IO::Memory.new(Base64.decode(continuation)) + cursor = URI.decode_www_form(continuation) + .try { |i| Base64.decode(i) } + .try { |i| IO::Memory.new(i) } + .try { |i| Protodec::Any.parse(i) } + .try { |i| Protodec::Any.cast_json(i["80226972:0:embedded"]["3:1:base64"].as_h) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } - # 0xe2 0xa9 0x85 0xb2 0x02 - data.pos += 5 - - continuation = Bytes.new(data.read_bytes(VarInt)) - data.read continuation - data = IO::Memory.new(continuation) - - data.read_byte # => 0x12 - ucid = Bytes.new(data.read_bytes(VarInt)) - data.read ucid - - data.read_byte # => 0x1a - until data.peek[0] == 'E'.ord - data.read_byte - end - - return URI.decode_www_form(data.gets_to_end) + cursor end def get_about_info(ucid, locale) diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index d4fc2c6f..2d7bc1cf 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -572,129 +572,84 @@ def content_to_comment_html(content) end def extract_comment_cursor(continuation) - continuation = URI.decode_www_form(continuation) - data = IO::Memory.new(Base64.decode(continuation)) + cursor = URI.decode_www_form(continuation) + .try { |i| Base64.decode(i) } + .try { |i| IO::Memory.new(i) } + .try { |i| Protodec::Any.parse(i) } + .try { |i| i["6:2:embedded"]["1:0:string"].as_s } - # 0x12 0x26 - data.pos += 2 - - data.read_byte # => 0x12 - video_id = Bytes.new(data.read_bytes(VarInt)) - data.read video_id - - until data.peek[0] == 0x0a - data.read_byte - end - data.read_byte # 0x0a - data.read_byte if data.peek[0] == 0x0a - - cursor = Bytes.new(data.read_bytes(VarInt)) - data.read cursor - - String.new(cursor) + return cursor end def produce_comment_continuation(video_id, cursor = "", sort_by = "top") - data = IO::Memory.new + object = { + "2:embedded" => { + "2:string" => video_id, + "24:varint" => 1_i64, + "25:varint" => 1_i64, + "28:varint" => 1_i64, + "36:embedded" => { + "5:varint" => -1_i64, + "8:varint" => 0_i64, + }, + }, + "3:varint" => 6_i64, + "6:embedded" => { + "1:string" => cursor, + "4:embedded" => { + "4:string" => video_id, + "6:varint" => 0_i64, + }, + "5:varint" => 20_i64, + }, + } - data.write Bytes[0x12, 0x26] - - data.write_byte 0x12 - VarInt.to_io(data, video_id.bytesize) - data.print video_id - - data.write Bytes[0xc0, 0x01, 0x01] - data.write Bytes[0xc8, 0x01, 0x01] - data.write Bytes[0xe0, 0x01, 0x01] - - data.write Bytes[0xa2, 0x02, 0x0d] - data.write Bytes[0x28, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01] - - data.write Bytes[0x40, 0x00] - data.write Bytes[0x18, 0x06] - - if cursor.empty? - data.write Bytes[0x32] - VarInt.to_io(data, cursor.bytesize + video_id.bytesize + 8) - - data.write Bytes[0x22, video_id.bytesize + 4] - data.write Bytes[0x22, video_id.bytesize] - data.print video_id - - case sort_by - when "top" - data.write Bytes[0x30, 0x00] - when "new", "newest" - data.write Bytes[0x30, 0x01] - end - - data.write(Bytes[0x78, 0x02]) - else - data.write Bytes[0x32] - VarInt.to_io(data, cursor.bytesize + video_id.bytesize + 11) - - data.write_byte 0x0a - VarInt.to_io(data, cursor.bytesize) - data.print cursor - - data.write Bytes[0x22, video_id.bytesize + 4] - data.write Bytes[0x22, video_id.bytesize] - data.print video_id - - case sort_by - when "top" - data.write Bytes[0x30, 0x00] - when "new", "newest" - data.write Bytes[0x30, 0x01] - end - - data.write Bytes[0x28, 0x14] + case sort_by + when "top" + object["6:embedded"].as(Hash)["4:embedded"].as(Hash)["6:varint"] = 0_i64 + when "new", "newest" + object["6:embedded"].as(Hash)["4:embedded"].as(Hash)["6:varint"] = 1_i64 end - continuation = Base64.urlsafe_encode(data) - continuation = URI.encode_www_form(continuation) + continuation = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } + .try { |i| URI.encode_www_form(i) } return continuation end def produce_comment_reply_continuation(video_id, ucid, comment_id) - data = IO::Memory.new + object = { + "2:embedded" => { + "2:string" => video_id, + "24:varint" => 1_i64, + "25:varint" => 1_i64, + "28:varint" => 1_i64, + "36:embedded" => { + "5:varint" => -1_i64, + "8:varint" => 0_i64, + }, + }, + "3:varint" => 6_i64, + "6:embedded" => { + "3:embedded" => { + "2:string" => comment_id, + "4:embedded" => { + "1:varint" => 0_i64, + }, + "5:string" => ucid, + "6:string" => video_id, + "8:varint" => 1_i64, + "9:varint" => 10_i64, + }, + }, + } - data.write Bytes[0x12, 0x26] - - data.write_byte 0x12 - VarInt.to_io(data, video_id.size) - data.print video_id - - data.write Bytes[0xc0, 0x01, 0x01] - data.write Bytes[0xc8, 0x01, 0x01] - data.write Bytes[0xe0, 0x01, 0x01] - - data.write Bytes[0xa2, 0x02, 0x0d] - data.write Bytes[0x28, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01] - - data.write Bytes[0x40, 0x00] - data.write Bytes[0x18, 0x06] - - data.write(Bytes[0x32, ucid.size + video_id.size + comment_id.size + 16]) - data.write(Bytes[0x1a, ucid.size + video_id.size + comment_id.size + 14]) - - data.write_byte 0x12 - VarInt.to_io(data, comment_id.size) - data.print comment_id - - data.write(Bytes[0x22, 0x02, 0x08, 0x00]) # ? - - data.write(Bytes[ucid.size + video_id.size + 7]) - data.write(Bytes[ucid.size]) - data.print(ucid) - data.write(Bytes[0x32, video_id.size]) - data.print(video_id) - data.write(Bytes[0x40, 0x01]) - data.write(Bytes[0x48, 0x0a]) - - continuation = Base64.urlsafe_encode(data.to_slice) - continuation = URI.encode_www_form(continuation) + continuation = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } + .try { |i| URI.encode_www_form(i) } return continuation end diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 8d071acc..9c8afd3c 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -327,48 +327,28 @@ def produce_playlist_url(id, index) if id.starts_with? "UC" id = "UU" + id.lchop("UC") end - ucid = "VL" + id + plid = "VL" + id - data = IO::Memory.new - data.write_byte 0x08 - VarInt.to_io(data, index) + data = {"1:varint" => index.to_i64} + .try { |i| Protodec::Any.cast_json(i) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i, padding: false) } - data.rewind - data = Base64.urlsafe_encode(data, false) - data = "PT:#{data}" + object = { + "80226972:embedded" => { + "2:string" => plid, + "3:base64" => { + "15:string" => "PT:#{data}", + }, + }, + } - continuation = IO::Memory.new - continuation.write_byte 0x7a - VarInt.to_io(continuation, data.bytesize) - continuation.print data + continuation = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } + .try { |i| URI.encode_www_form(i) } - data = Base64.urlsafe_encode(continuation) - cursor = URI.encode_www_form(data) - - data = IO::Memory.new - - data.write_byte 0x12 - VarInt.to_io(data, ucid.bytesize) - data.print ucid - - data.write_byte 0x1a - VarInt.to_io(data, cursor.bytesize) - data.print cursor - - data.rewind - - buffer = IO::Memory.new - buffer.write Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02] - VarInt.to_io(buffer, data.bytesize) - - IO.copy data, buffer - - continuation = Base64.urlsafe_encode(buffer) - continuation = URI.encode_www_form(continuation) - - url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" - - return url + return "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" end def get_playlist(db, plid, locale, refresh = true, force_refresh = false) diff --git a/src/invidious/search.cr b/src/invidious/search.cr index 2acb4057..cc9c9634 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -281,152 +281,116 @@ end def produce_search_params(sort : String = "relevance", date : String = "", content_type : String = "", duration : String = "", features : Array(String) = [] of String) - header = IO::Memory.new - header.write Bytes[0x08] - header.write case sort + object = { + "1:varint" => 0_i64, + "2:embedded" => {} of String => Int64, + } + + case sort when "relevance" - Bytes[0x00] + object["1:varint"] = 0_i64 when "rating" - Bytes[0x01] + object["1:varint"] = 1_i64 when "upload_date", "date" - Bytes[0x02] + object["1:varint"] = 2_i64 when "view_count", "views" - Bytes[0x03] + object["1:varint"] = 3_i64 else raise "No sort #{sort}" end - body = IO::Memory.new - body.write case date + case date when "hour" - Bytes[0x08, 0x01] + object["2:embedded"].as(Hash)["1:varint"] = 1_i64 when "today" - Bytes[0x08, 0x02] + object["2:embedded"].as(Hash)["1:varint"] = 2_i64 when "week" - Bytes[0x08, 0x03] + object["2:embedded"].as(Hash)["1:varint"] = 3_i64 when "month" - Bytes[0x08, 0x04] + object["2:embedded"].as(Hash)["1:varint"] = 4_i64 when "year" - Bytes[0x08, 0x05] - else - Bytes.new(0) + object["2:embedded"].as(Hash)["1:varint"] = 5_i64 end - body.write case content_type + case content_type when "video" - Bytes[0x10, 0x01] + object["2:embedded"].as(Hash)["2:varint"] = 1_i64 when "channel" - Bytes[0x10, 0x02] + object["2:embedded"].as(Hash)["2:varint"] = 2_i64 when "playlist" - Bytes[0x10, 0x03] + object["2:embedded"].as(Hash)["2:varint"] = 3_i64 when "movie" - Bytes[0x10, 0x04] + object["2:embedded"].as(Hash)["2:varint"] = 4_i64 when "show" - Bytes[0x10, 0x05] + object["2:embedded"].as(Hash)["2:varint"] = 5_i64 when "all" - Bytes.new(0) + # else - Bytes[0x10, 0x01] + object["2:embedded"].as(Hash)["2:varint"] = 1_i64 end - body.write case duration + case duration when "short" - Bytes[0x18, 0x01] + object["2:embedded"].as(Hash)["3:varint"] = 1_i64 when "long" - Bytes[0x18, 0x12] - else - Bytes.new(0) + object["2:embedded"].as(Hash)["3:varint"] = 18_i64 end features.each do |feature| - body.write case feature + case feature when "hd" - Bytes[0x20, 0x01] + object["2:embedded"].as(Hash)["4:varint"] = 1_i64 when "subtitles" - Bytes[0x28, 0x01] + object["2:embedded"].as(Hash)["5:varint"] = 1_i64 when "creative_commons", "cc" - Bytes[0x30, 0x01] + object["2:embedded"].as(Hash)["6:varint"] = 1_i64 when "3d" - Bytes[0x38, 0x01] + object["2:embedded"].as(Hash)["7:varint"] = 1_i64 when "live", "livestream" - Bytes[0x40, 0x01] + object["2:embedded"].as(Hash)["8:varint"] = 1_i64 when "purchased" - Bytes[0x48, 0x01] + object["2:embedded"].as(Hash)["9:varint"] = 1_i64 when "4k" - Bytes[0x70, 0x01] + object["2:embedded"].as(Hash)["14:varint"] = 1_i64 when "360" - Bytes[0x78, 0x01] + object["2:embedded"].as(Hash)["15:varint"] = 1_i64 when "location" - Bytes[0xb8, 0x01, 0x01] + object["2:embedded"].as(Hash)["23:varint"] = 1_i64 when "hdr" - Bytes[0xc8, 0x01, 0x01] - else - Bytes.new(0) + object["2:embedded"].as(Hash)["25:varint"] = 1_i64 end end - token = header - if !body.empty? - token.write Bytes[0x12, body.bytesize] - token.write body.to_slice - end + params = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i, padding: false) } - token = Base64.urlsafe_encode(token.to_slice) - token = URI.encode_www_form(token) - - return token + return params end def produce_channel_search_url(ucid, query, page) - page = "#{page}" + object = { + "80226972:embedded" => { + "2:string" => ucid, + "3:base64" => { + "2:string" => "search", + "6:varint" => 2_i64, + "7:varint" => 1_i64, + "12:varint" => 1_i64, + "13:string" => "", + "23:varint" => 0_i64, + "15:string" => "#{page}", + }, + "11:string" => query, + }, + } - data = IO::Memory.new - data.write_byte 0x12 - data.write_byte 0x06 - data.print "search" + continuation = object.try { |i| Protodec::Any.cast_json(object) } + .try { |i| Protodec::Any.from_json(i) } + .try { |i| Base64.urlsafe_encode(i) } + .try { |i| URI.encode_www_form(i) } - data.write Bytes[0x30, 0x02] - data.write Bytes[0x38, 0x01] - data.write Bytes[0x60, 0x01] - data.write Bytes[0x6a, 0x00] - data.write Bytes[0xb8, 0x01, 0x00] - - data.write_byte 0x7a - VarInt.to_io(data, page.bytesize) - data.print page - - data.rewind - data = Base64.urlsafe_encode(data) - continuation = URI.encode_www_form(data) - - data = IO::Memory.new - - data.write_byte 0x12 - VarInt.to_io(data, ucid.bytesize) - data.print ucid - - data.write_byte 0x1a - VarInt.to_io(data, continuation.bytesize) - data.print continuation - - data.write_byte 0x5a - VarInt.to_io(data, query.bytesize) - data.print query - - data.rewind - - buffer = IO::Memory.new - buffer.write Bytes[0xe2, 0xa9, 0x85, 0xb2, 0x02] - VarInt.to_io(buffer, data.bytesize) - - IO.copy data, buffer - - continuation = Base64.urlsafe_encode(buffer) - continuation = URI.encode_www_form(continuation) - - url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" - - return url + return "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" end def process_search_query(query, page, user, region)