diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | kubernetes/Chart.yaml | 2 | ||||
| -rw-r--r-- | kubernetes/templates/deployment.yaml | 8 | ||||
| -rw-r--r-- | kubernetes/templates/service.yaml | 6 | ||||
| -rw-r--r-- | kubernetes/values.yaml | 5 | ||||
| -rw-r--r-- | src/invidious/channels.cr | 8 | ||||
| -rw-r--r-- | src/invidious/helpers/helpers.cr | 16 | ||||
| -rw-r--r-- | src/invidious/playlists.cr | 2 |
8 files changed, 33 insertions, 16 deletions
@@ -92,7 +92,7 @@ $ curl -sSL https://dist.crystal-lang.org/apt/setup.sh | sudo bash $ curl -sL "https://keybase.io/crystal/pgp_keys.asc" | sudo apt-key add - $ echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list $ sudo apt-get update -$ sudo apt install crystal libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin libsqlite3-dev +$ sudo apt install crystal libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin libsqlite3-dev zlib1g-dev ``` #### Add an Invidious user and clone the repository diff --git a/kubernetes/Chart.yaml b/kubernetes/Chart.yaml index 0d7791d7..bb0838ad 100644 --- a/kubernetes/Chart.yaml +++ b/kubernetes/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: invidious description: Invidious is an alternative front-end to YouTube -version: 1.0.0 +version: 1.1.0 appVersion: 0.20.1 keywords: - youtube diff --git a/kubernetes/templates/deployment.yaml b/kubernetes/templates/deployment.yaml index 34156127..bb0b832f 100644 --- a/kubernetes/templates/deployment.yaml +++ b/kubernetes/templates/deployment.yaml @@ -23,6 +23,13 @@ spec: runAsUser: {{ .Values.securityContext.runAsUser }} runAsGroup: {{ .Values.securityContext.runAsGroup }} fsGroup: {{ .Values.securityContext.fsGroup }} + initContainers: + - name: wait-for-postgresql + image: postgres + args: + - /bin/sh + - -c + - until pg_isready -h {{ .Values.config.db.host }} -p {{ .Values.config.db.port }} -U {{ .Values.config.db.user }}; do echo waiting for database; sleep 2; done; containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -50,4 +57,5 @@ spec: httpGet: port: 3000 path: / + initialDelaySeconds: 15 restartPolicy: Always diff --git a/kubernetes/templates/service.yaml b/kubernetes/templates/service.yaml index 56bdea2e..01454d4e 100644 --- a/kubernetes/templates/service.yaml +++ b/kubernetes/templates/service.yaml @@ -7,10 +7,14 @@ metadata: chart: {{ .Chart.Name }} release: {{ .Release.Name }} spec: + type: {{ .Values.service.type }} ports: - name: http - port: 3000 + port: {{ .Values.service.port }} targetPort: 3000 selector: app: {{ template "invidious.name" . }} release: {{ .Release.Name }} +{{- if .Values.service.loadBalancerIP }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} +{{- end }} diff --git a/kubernetes/values.yaml b/kubernetes/values.yaml index ce32b257..4d037022 100644 --- a/kubernetes/values.yaml +++ b/kubernetes/values.yaml @@ -13,6 +13,11 @@ autoscaling: maxReplicas: 16 targetCPUUtilizationPercentage: 50 +service: + type: clusterIP + port: 3000 + #loadBalancerIP: + resources: {} #requests: # cpu: 100m diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index c5600291..6dbcf6cc 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -403,7 +403,7 @@ def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = " object["80226972:embedded"]["3:base64"].as(Hash)["61:string"] = Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json({ "1:embedded" => { - "1:varint" => 6307666885028338688_i64, + "1:varint" => 6307666885028338688_i64, "2:embedded" => { "1:string" => Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json({ "1:varint" => 30_i64 * (page - 1), @@ -896,9 +896,9 @@ def get_channel_videos_response(ucid, page = 1, auto_generated = nil, sort_by = return response if !initial_data needs_v2 = initial_data .try &.["response"]?.try &.["alerts"]? - .try &.as_a.any? { |alert| - alert.try &.["alertRenderer"]?.try &.["type"]?.try { |t| t == "ERROR" } - } + .try &.as_a.any? { |alert| + alert.try &.["alertRenderer"]?.try &.["type"]?.try { |t| t == "ERROR" } + } if needs_v2 url = produce_channel_videos_url(ucid, page, auto_generated: auto_generated, sort_by: sort_by, v2: true) response = YT_POOL.client &.get(url) diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 6571f818..fb220eab 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -177,8 +177,8 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa view_count = i["viewCountText"]?.try &.["simpleText"]?.try &.as_s.gsub(/\D+/, "").to_i64? || 0_i64 description_html = i["descriptionSnippet"]?.try { |t| parse_content(t) } || "" length_seconds = i["lengthText"]?.try &.["simpleText"]?.try &.as_s.try { |t| decode_length_seconds(t) } || - i["thumbnailOverlays"]?.try &.as_a.find(&.["thumbnailOverlayTimeStatusRenderer"]?).try &.["thumbnailOverlayTimeStatusRenderer"]? - .try &.["text"]?.try &.["simpleText"]?.try &.as_s.try { |t| decode_length_seconds(t) } || 0 + i["thumbnailOverlays"]?.try &.as_a.find(&.["thumbnailOverlayTimeStatusRenderer"]?).try &.["thumbnailOverlayTimeStatusRenderer"]? + .try &.["text"]?.try &.["simpleText"]?.try &.as_s.try { |t| decode_length_seconds(t) } || 0 live_now = false paid = false @@ -302,14 +302,14 @@ def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : Stri channel_v2_response = initial_data .try &.["response"]? - .try &.["continuationContents"]? - .try &.["gridContinuation"]? - .try &.["items"]? + .try &.["continuationContents"]? + .try &.["gridContinuation"]? + .try &.["items"]? if channel_v2_response channel_v2_response.try &.as_a.each { |item| - extract_item(item, author_fallback, author_id_fallback) - .try { |t| items << t } + extract_item(item, author_fallback, author_id_fallback) + .try { |t| items << t } } else initial_data.try { |t| t["contents"]? || t["response"]? } @@ -325,7 +325,7 @@ def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : Stri extract_item(item, author_fallback, author_id_fallback) .try { |t| items << t } } } - end + end items end diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 9190e4e6..c984a12a 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -483,7 +483,7 @@ def extract_playlist_videos(initial_data : Hash(String, JSON::Any)) published: Time.utc, plid: plid, live_now: live, - index: index - 1, + index: index, }) end end |
