summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-06-10 18:04:16 +0200
committerSamantaz Fox <coding@samantaz.fr>2023-06-11 16:34:59 +0200
commit69f23d95b8ab719ca4f19649ce105fa29786913c (patch)
tree5534618b0ad1bf2970bbb9dbeca08c8ac3efc46c /src
parent34441178182cb96e93d679230103005b86e3b35b (diff)
downloadinvidious-69f23d95b8ab719ca4f19649ce105fa29786913c.tar.gz
invidious-69f23d95b8ab719ca4f19649ce105fa29786913c.tar.bz2
invidious-69f23d95b8ab719ca4f19649ce105fa29786913c.zip
User: Remove broken Google login (various functions)
Diffstat (limited to 'src')
-rw-r--r--src/invidious/helpers/helpers.cr25
-rw-r--r--src/invidious/users.cr69
2 files changed, 0 insertions, 94 deletions
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index c3b53339..23ff0da9 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -22,31 +22,6 @@ struct Annotation
property annotations : String
end
-def login_req(f_req)
- data = {
- # Unfortunately there's not much information available on `bgRequest`; part of Google's BotGuard
- # Generally this is much longer (>1250 characters), see also
- # https://github.com/ytdl-org/youtube-dl/commit/baf67a604d912722b0fe03a40e9dc5349a2208cb .
- # For now this can be empty.
- "bgRequest" => %|["identifier",""]|,
- "pstMsg" => "1",
- "checkConnection" => "youtube",
- "checkedDomains" => "youtube",
- "hl" => "en",
- "deviceinfo" => %|[null,null,null,[],null,"US",null,null,[],"GlifWebSignIn",null,[null,null,[]]]|,
- "f.req" => f_req,
- "flowName" => "GlifWebSignIn",
- "flowEntry" => "ServiceLogin",
- # "cookiesDisabled" => "false",
- # "gmscoreversion" => "undefined",
- # "continue" => "https://accounts.google.com/ManageAccount",
- # "azt" => "",
- # "bgHash" => "",
- }
-
- return HTTP::Params.encode(data)
-end
-
def html_to_content(description_html : String)
description = description_html.gsub(/(<br>)|(<br\/>)/, {
"<br>": "\n",
diff --git a/src/invidious/users.cr b/src/invidious/users.cr
index dc36c61e..65566d20 100644
--- a/src/invidious/users.cr
+++ b/src/invidious/users.cr
@@ -3,75 +3,6 @@ require "crypto/bcrypt/password"
# Materialized views may not be defined using bound parameters (`$1` as used elsewhere)
MATERIALIZED_VIEW_SQL = ->(email : String) { "SELECT cv.* FROM channel_videos cv WHERE EXISTS (SELECT subscriptions FROM users u WHERE cv.ucid = ANY (u.subscriptions) AND u.email = E'#{email.gsub({'\'' => "\\'", '\\' => "\\\\"})}') ORDER BY published DESC" }
-def get_user(sid, headers, refresh = true)
- if email = Invidious::Database::SessionIDs.select_email(sid)
- user = Invidious::Database::Users.select!(email: email)
-
- if refresh && Time.utc - user.updated > 1.minute
- user, sid = fetch_user(sid, headers)
-
- Invidious::Database::Users.insert(user, update_on_conflict: true)
- Invidious::Database::SessionIDs.insert(sid, user.email, handle_conflicts: true)
-
- begin
- view_name = "subscriptions_#{sha256(user.email)}"
- PG_DB.exec("CREATE MATERIALIZED VIEW #{view_name} AS #{MATERIALIZED_VIEW_SQL.call(user.email)}")
- rescue ex
- end
- end
- else
- user, sid = fetch_user(sid, headers)
-
- Invidious::Database::Users.insert(user, update_on_conflict: true)
- Invidious::Database::SessionIDs.insert(sid, user.email, handle_conflicts: true)
-
- begin
- view_name = "subscriptions_#{sha256(user.email)}"
- PG_DB.exec("CREATE MATERIALIZED VIEW #{view_name} AS #{MATERIALIZED_VIEW_SQL.call(user.email)}")
- rescue ex
- end
- end
-
- return user, sid
-end
-
-def fetch_user(sid, headers)
- feed = YT_POOL.client &.get("/subscription_manager?disable_polymer=1", headers)
- feed = XML.parse_html(feed.body)
-
- channels = feed.xpath_nodes(%q(//ul[@id="guide-channels"]/li/a)).compact_map do |channel|
- if {"Popular on YouTube", "Music", "Sports", "Gaming"}.includes? channel["title"]
- nil
- else
- channel["href"].lstrip("/channel/")
- end
- end
-
- channels = get_batch_channels(channels)
-
- email = feed.xpath_node(%q(//a[@class="yt-masthead-picker-header yt-masthead-picker-active-account"]))
- if email
- email = email.content.strip
- else
- email = ""
- end
-
- token = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
-
- user = Invidious::User.new({
- updated: Time.utc,
- notifications: [] of String,
- subscriptions: channels,
- email: email,
- preferences: Preferences.new(CONFIG.default_user_preferences.to_tuple),
- password: nil,
- token: token,
- watched: [] of String,
- feed_needs_update: true,
- })
- return user, sid
-end
-
def create_user(sid, email, password)
password = Crypto::Bcrypt::Password.create(password, cost: 10)
token = Base64.urlsafe_encode(Random::Secure.random_bytes(32))