Replace Youtube Trailer Add-on with Invidious
#1
Gents
I have finally managed to replace the Youtube Add-on with Invidious to play my movie trailers.
My setup includes the Universal Movie Scraper which places the link to the trailer with the Youtube Add-on in the Videos database.

The procedure is the following:
1. Install the Invidious Add-on - https://kodi.tv/addons/matrix/plugin.video.invidious
2. Replace the entry in the Videos database with the Invidious specific link. For this you have to login to the Kodi on the command line and use the following bash/SQL snippets:
2a) systemctl stop kodi
2b) sqlite3 .kodi/userdata/Database/MyVideos119.db
2c) UPDATE movie SET c19 = REPLACE(c19,'youtube/?action=play_video&videoid','invidious/?action=video&videoId');
2d) systemctl restart kodi

Now the trailers are playing seamlessly via the trailer button on the movies detail page.
Next I plan to replace the periodic and manual procedure with a bash script and automate the update eg. on every start (or shutdown) - any suggestions on how to trigger this?

Bonus: Also the "Play to Kodi" Browser plugin works for me when you change the Youtube references to Invidious in your local plugin respectively - so I can beam content (eg. trailers) from my laptop browser to the kodi box.
Reply
#2
Nice write up, appreciate the info on the replacement youtube plugin.

However... I have a far simpler solution. Hijack plugin.video.youtube

Specifically:

Open addon.xml in .kodi/addons/plugin.video.invidious

Replace line 2

<addon id="plugin.video.youtube" name="Invidious" version="0.1.0+matrix.1" provider-name="TheAssassin">

Next you need to handle urls passed so open invidious_plugin.py in .kodi/addons/plugin.video.invidious/resources/lib/

Line 145, change to action = self.args.get("action", ["play_video"])[0] from this sets the default action when action isn't set to play_video instead of none

Line 194, change to base_url = sys.argv[0].replace("/play/","/") just strip out the /play so the url it's correct for invidious

Profit.

Make sure the real plugin.video.youtube isn't actually installed to complain about being taken over.

Far easier than constantly updating the database I would say.
Reply
#3
Hi
I'd like to use this, but unfortunately won't work for me - this is the error I get:
Quote:File "/home/xxx/.kodi/addons/plugin.video.invidious/resources/lib/invidious_plugin.py", line 164, in run
        self.play_video(self.args["video_id"][0])
KeyError: 'video_id'
anybody any idea?
thanks
Reply
#4
(2023-03-12, 21:51)BriseBise Wrote: Hi
I'd like to use this, but unfortunately won't work for me - this is the error I get:
Quote:File "/home/xxx/.kodi/addons/plugin.video.invidious/resources/lib/invidious_plugin.py", line 164, in run
        self.play_video(self.args["video_id"][0])
KeyError: 'video_id'
anybody any idea?
thanks

Good news! This is fortunately a very easy fix. The key used when Kodi requests a trailer (as stored in the database) is "videoid", rather than "video_id", which is what's used in some other contexts (e.g. sharing a video to Kodi via the Kore mobile app). In order to handle both of these keys, you can use a simple conditional in Python in the function defined on line 164 of invidious_plugin.py:

Code:

            elif action == "play_video":
                if "video_id" in self.args:
                    self.play_video(self.args["video_id"][0])
                elif "videoid" in self.args:
                    self.play_video(self.args["videoid"][0])
                raise RuntimeError("unknown action " + action)

<rant removed>

Sorry, quick correction, I miscopied: that runtime error should be raised in an else block, as follows:

            elif action == "play_video":
                if "video_id" in self.args:
                    self.play_video(self.args["video_id"][0])
                elif "videoid" in self.args:
                    self.play_video(self.args["videoid"][0])
               else:
                   raise RuntimeError("unknown action " + action)

<rant removed>
Reply
#5
I tried version 2.2.4 with CoreElec 20.5 but after performing a search inside the addon it gives a lot of errors.
wuvawiqiha.kodi (paste)
Is this addon still supported?
Reply

Logout Mark Read Team Forum Stats Members Help
Replace Youtube Trailer Add-on with Invidious0