diff options
author | Case Duckworth | 2022-07-18 09:33:09 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-18 09:33:09 -0500 |
commit | 99dd02979bd263b80fad9b4859ddcaed58e46cc0 (patch) | |
tree | 4a901ee5f925a1ef5ac4836ff06e1bf66ca88973 | |
parent | Filter titles and things (diff) | |
download | sfeed-99dd02979bd263b80fad9b4859ddcaed58e46cc0.tar.gz sfeed-99dd02979bd263b80fad9b4859ddcaed58e46cc0.zip |
Convert youtube -> invidious
-rwxr-xr-x | runsfeed | 9 | ||||
-rwxr-xr-x | sfeed_html.sh | 8 | ||||
-rw-r--r-- | sfeedrc | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/runsfeed b/runsfeed index 7bafcc0..f108031 100755 --- a/runsfeed +++ b/runsfeed | |||
@@ -19,6 +19,8 @@ main() { | |||
19 | test -d "$(dirname "$sfeedrc")" || mkdir -p "$(dirname "$sfeedrc")" | 19 | test -d "$(dirname "$sfeedrc")" || mkdir -p "$(dirname "$sfeedrc")" |
20 | test -d "$sfeedpath" || mkdir -p "$sfeedpath" | 20 | test -d "$sfeedpath" || mkdir -p "$sfeedpath" |
21 | 21 | ||
22 | log Finding Invidious host... | ||
23 | get_invidious_url "https://api.invidious.io/instances.json?sort_by=health" | ||
22 | log Updating feeds... | 24 | log Updating feeds... |
23 | update "$sfeedrc" | 25 | update "$sfeedrc" |
24 | log Generating HTML... | 26 | log Generating HTML... |
@@ -36,6 +38,13 @@ main() { | |||
36 | log Done. | 38 | log Done. |
37 | } | 39 | } |
38 | 40 | ||
41 | get_invidious_url() { | ||
42 | curl -sL "$1" | | ||
43 | jq -r .[][1].uri | | ||
44 | grep -v onion | | ||
45 | head -n1 | tee /tmp/invidious.host | ||
46 | } | ||
47 | |||
39 | log() { | 48 | log() { |
40 | printf '%s\n' "$*" >&2 | 49 | printf '%s\n' "$*" >&2 |
41 | } | 50 | } |
diff --git a/sfeed_html.sh b/sfeed_html.sh index 86aad43..321d451 100755 --- a/sfeed_html.sh +++ b/sfeed_html.sh | |||
@@ -67,6 +67,12 @@ $(for file in "$@"; do html_feed "$file"; done) | |||
67 | EOF | 67 | EOF |
68 | } | 68 | } |
69 | 69 | ||
70 | filter_invidious() { | ||
71 | # Convert youtube links to invidious links | ||
72 | host="$(cat /tmp/invidious.host)" | ||
73 | sed "s@https://www\.youtube\.com@${host}@" | ||
74 | } | ||
75 | |||
70 | html_feed() { # html_feed FEED(file) => HTML | 76 | html_feed() { # html_feed FEED(file) => HTML |
71 | filename="$(basename "$1")" | 77 | filename="$(basename "$1")" |
72 | now="$(date +%s)" | 78 | now="$(date +%s)" |
@@ -136,7 +142,7 @@ html_feed() { # html_feed FEED(file) => HTML | |||
136 | printf "<a href=\"#%s\">%s</a></li>\n", NAME, NAME >> ASIDE | 142 | printf "<a href=\"#%s\">%s</a></li>\n", NAME, NAME >> ASIDE |
137 | } | 143 | } |
138 | printf "%s", (stamp ? stamp : ".") > "/dev/stderr" | 144 | printf "%s", (stamp ? stamp : ".") > "/dev/stderr" |
139 | }' "$1")" | 145 | }' "$1" | filter_invidious)" |
140 | if [ -z "$entries" ]; then return 1; fi | 146 | if [ -z "$entries" ]; then return 1; fi |
141 | echo "<section id=\"$filename\">" | 147 | echo "<section id=\"$filename\">" |
142 | # TODO: Include a link back to the website | 148 | # TODO: Include a link back to the website |
diff --git a/sfeedrc b/sfeedrc index 136eaf9..772f19b 100644 --- a/sfeedrc +++ b/sfeedrc | |||
@@ -178,7 +178,7 @@ filter_add_empties() { | |||
178 | 178 | ||
179 | filter_embed_youtube() { | 179 | filter_embed_youtube() { |
180 | # replace youtube links with embed links | 180 | # replace youtube links with embed links |
181 | sed 's@www.youtube.com/watch?v=@www.youtube.com/embed/@g' | 181 | sed 's@www\.youtube\.com/watch?v=@www.youtube.com/embed/@g' |
182 | } | 182 | } |
183 | 183 | ||
184 | filter_filter_links() { | 184 | filter_filter_links() { |