This addon will replace "youtube.com" with the chosen Invidious instance #1441
No reviewers
Labels
No labels
2018.09
2019.01
2019.03
2019.06
2019.09
2019.12
2020.03
2020.06
2020.09
2020.12
2021.03
2021.07
2021.09
2022.02
2022.06
2022.09
2022.12
2023.04
2023.05
2023.09
2024.03
2024.06
2024.09
2024.12
dependencies
Hackathon 2021
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: friendica/friendica-addons#1441
Loading…
Reference in a new issue
No description provided.
Delete branch ":develop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -0,0 +50,4 @@
$b['html'] = str_replace('https://www.youtube.com', $invidious, $b['html']);
$replaced = true;
}
if (strstr($b['html'], 'https://youtube.com')) {
Why is this block duplicated?
To ensure that different spellings with www and without are intercepted and redirected.
Thanks for the reply, the indentation still needs to be corrected.
you could combine the
str_replace
with an array as first parameter.I just saw: You could even make it user configurable. You just have to use
DI::userSession()->getLocalUserId()
to fetch the user id.@heluecht That would be great. The user should be able to control it themselves. I'm just afraid that my skills are not sufficient for these changes.
@heluecht Here is a suggestion as to how the URLs can be combined with each other.
@ -0,0 +54,4 @@
foreach ($youtubeUrls as $youtubeUrl) {
if (strstr($b['html'], $youtubeUrl)) {
$b['html'] = str_replace($youtubeUrl, $invidious, $b['html']);
You can simply do
@ -0,0 +46,4 @@
// this needs to be a system setting
$replaced = false;
$invidious = DI::config()->get('invidious', 'server', 'https://invidio.us');
if (strstr($b['html'], 'https://www.youtube.com')) {
You need to also check for
'https://youtube.com'
now that the replacement has been combined. Additionallystrpos()
has better performance for what you're trying to do here.And what about
https://youtu.be/[video id]
links? They need to be replaced by[Invidious domain]/?watch=[video id]
.Lastly, I added an ending slash to the needle strings to match video links. If someone just mentions youtube.com and links to it, it shouldn't be replaced with an Invidious link.
Looks good to me. @heluecht ?