yewtudotbe / invidious-custom

Invidious with some git patches (mostly from existing PRs)
GNU Affero General Public License v3.0
211 stars 43 forks source link

Have streams URLs generated for the specific proxy server #9

Closed unixfox closed 2 years ago

unixfox commented 2 years ago

Right now the streams URLs are generated from a random server and the server that will serve the videoplayback media will be random.

This break the protected streams URLs and could be the issue of the throttling.

unixfox commented 2 years ago

bump

unixfox commented 2 years ago
require "./base.cr"

module Invidious::Database::Videos
  extend self

  def insert(video : Video)
    request = <<-SQL
      INSERT INTO videos
      VALUES ($1, $2, $3)
      ON CONFLICT (id) DO NOTHING
    SQL

    ENV.fetch("SALUT", "")
    PG_DB.exec(request, video.id + ENV.fetch("NODE_NAME", ""), video.info.to_json, video.updated)
  end

  def delete(id)
    request = <<-SQL
      DELETE FROM videos *
      WHERE id = $1
    SQL

    PG_DB.exec(request, id + ENV.fetch("NODE_NAME", ""))
  end

  def update(video : Video)
    request = <<-SQL
      UPDATE videos
      SET (id, info, updated) = ($1, $2, $3)
      WHERE id = $1
    SQL

    PG_DB.exec(request, video.id + ENV.fetch("NODE_NAME", ""), video.info.to_json, video.updated)
  end

  def select(id : String) : Video?
    request = <<-SQL
      SELECT * FROM videos
      WHERE id = $1
    SQL

    return PG_DB.query_one?(request, id + ENV.fetch("NODE_NAME", ""), as: Video)
  end
end
unixfox commented 2 years ago

Use https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/, need to upgrade to Kubernetes 1.23.

And use external domains for each proxy, this way the videoplayback URL is correctly generated.

unixfox commented 2 years ago

Use kubernetes.io/docs/concepts/services-networking/service-traffic-policy, need to upgrade to Kubernetes 1.23.

And use external domains for each proxy, this way the videoplayback URL is correctly generated.

Not sure if this is going to work as nginx fetches the IP addresses and doesn't use the service IP address. Probably would want to force the service IP instead.

unixfox commented 2 years ago

Fixed used: