From 094466ec5a37e7bf9e1fa57e43d6a86fceb09049 Mon Sep 17 00:00:00 2001 From: konsthol Date: Sat, 19 Apr 2025 20:48:19 +0300 Subject: [PATCH] Derp. Fix missing constant post rename --- css/style.css | 11 +- gophermap | 7 +- index.gmi | 7 +- index.html | 13 +- ...simple_way_to_extend_yt_dlp-12-01-2025.gmi | 75 +++++++++ ...imple_way_to_extend_yt_dlp-12-01-2025.html | 151 ++++++++++++++++++ ...simple_way_to_extend_yt_dlp-12-01-2025.txt | 128 +++++++++++++++ log_archive.gmi | 4 + log_archive.html | 14 +- log_archive.txt | 6 + rss.xml | 119 ++++++++++++++ 11 files changed, 516 insertions(+), 19 deletions(-) create mode 100644 log/simple_way_to_extend_yt_dlp-12-01-2025.gmi create mode 100644 log/simple_way_to_extend_yt_dlp-12-01-2025.html create mode 100644 log/simple_way_to_extend_yt_dlp-12-01-2025.txt diff --git a/css/style.css b/css/style.css index b06ea3f..17ece6c 100644 --- a/css/style.css +++ b/css/style.css @@ -62,7 +62,7 @@ section { } blockquote { - text-align: center; + text-align: center; margin:0 auto; width:auto; display:table @@ -82,13 +82,16 @@ pre { code, pre { font-family: "Comic Mono", monospace; - font-size: 1.0em; + /* font-size: 1.0em; */ + font-size: .9em; color: var(--color1); - text-align: center + /* text-align: center */ + text-align: left; } a { - font-size: .8em + /* font-size: .8em; (fixing it messes up mobile view) */ + font-size: .8em display: inline-block; text-align: left; text-justify: none; diff --git a/gophermap b/gophermap index ac0c6e1..4bb2db3 100644 --- a/gophermap +++ b/gophermap @@ -61,6 +61,7 @@ i konsthol.eu 70 i konsthol.eu 70 i## Log 📜 konsthol.eu 70 i konsthol.eu 70 +112-01-2025 - Simple way to extend yt-dlp /log/simple_way_to_extend_yt_dlp-12-01-2025.txt konsthol.eu 70 119-12-2024 - The magic of Wake-On-LAN /log/the_magic_of_wake_on_lan-19-12-2024.txt konsthol.eu 70 125-02-2023 - WebCall /log/webcall-25-02-2023.txt konsthol.eu 70 117-08-2022 - wpgtk is just more convenient /log/choose_wpgtk_over_just_pywal-17-08-2022.txt konsthol.eu 70 @@ -101,11 +102,11 @@ iI could be livestreaming at konsthol.eu 70 i konsthol.eu 70 hOwncast url:https://tv.konsthol.eu konsthol.eu 70 i konsthol.eu 70 -i## Piped 📹 konsthol.eu 70 +i## Invidious 📹 konsthol.eu 70 i konsthol.eu 70 -iMy Piped instance which you can use resides at konsthol.eu 70 +iMy Invidious instance which you can use, resides at konsthol.eu 70 i konsthol.eu 70 -hPiped url:https://piped.konsthol.eu/ konsthol.eu 70 +hInvidious url:https://piped.konsthol.eu/ konsthol.eu 70 i konsthol.eu 70 i## Gopher 🕳️ konsthol.eu 70 i konsthol.eu 70 diff --git a/index.gmi b/index.gmi index 12936ae..70ae92c 100644 --- a/index.gmi +++ b/index.gmi @@ -61,6 +61,7 @@ My Thesis can be found here ## Log 📜 +=> /log/simple_way_to_extend_yt_dlp-12-01-2025.gmi 12-01-2025 - Simple way to extend yt-dlp => /log/the_magic_of_wake_on_lan-19-12-2024.gmi 19-12-2024 - The magic of Wake-On-LAN => /log/webcall-25-02-2023.gmi 25-02-2023 - WebCall => /log/choose_wpgtk_over_just_pywal-17-08-2022.gmi 17-08-2022 - wpgtk is just more convenient @@ -101,11 +102,11 @@ I could be livestreaming at => https://tv.konsthol.eu Owncast -## Piped 📹 +## Invidious 📹 -My Piped instance which you can use resides at +My Invidious instance which you can use, resides at -=> https://piped.konsthol.eu/ Piped +=> https://piped.konsthol.eu/ Invidious ## Gopher 🕳️ diff --git a/index.html b/index.html index 6a169ea..c9c8293 100644 --- a/index.html +++ b/index.html @@ -88,6 +88,9 @@

Log 📜

+ 12-01-2025 - Simple way to extend yt-dlp
19-12-2024 - The magic of Wake-On-LAN
@@ -125,9 +128,9 @@

Owncast 📺

I could be livestreaming at

Owncast

-

Piped 📹

-

My Piped instance which you can use resides at

-

Piped

+

Invidious 📹

+

My Invidious instance which you can use, resides at

+

Invidious

Gopher 🕳️

My Gopher Hole for this homepage is accessible via

Gopher 🦫

@@ -182,8 +185,8 @@ function action() {

I accept donations for any reason

Donate

Daily Unique Visitors

-Saturday 28/12/24 15:36:55 -3 +Saturday 19/04/25 20:47:56 +2

Also on the web 🕸️

http website

diff --git a/log/simple_way_to_extend_yt_dlp-12-01-2025.gmi b/log/simple_way_to_extend_yt_dlp-12-01-2025.gmi new file mode 100644 index 0000000..17db331 --- /dev/null +++ b/log/simple_way_to_extend_yt_dlp-12-01-2025.gmi @@ -0,0 +1,75 @@ +> DATE: Sun 12 Jan 2025 15:51 By: konsthol@pm.me + +# Simple way to extend yt-dlp + +Lots of people use yt-dlp either directly or indirectly through mpv. It's a powerful tool that acts as a website scraper and it supports thousands of websites. The website its mostly used for is like the name suggests YouTube. Now, YouTube is a great resource but usage through the website is quite unpleasant so lots of people opt out to use alternative frontends like Invidious or Piped. Lots of times you just want to use mpv to stream a YouTube video by providing the link like: + +> mpv https://youtube.com/watch?v=[VideoID] + +That works like a charm, but what happens when you provide a link of an alternative frontend? Well, it translates it to the aforementioned format in order to work. But there are so many instances of Invidious and Piped, so how does it know what to do? That was my question as well since I use a self hosted Piped instance and it does not recognize the domain. Obviously. + +Thankfully, yt-dlp is an open source project so you can actually see what goes on behind the scenes. In my case, I installed it with the Arch Linux package manager and it resides at: + +> /usr/lib/python3.13/site-packages/yt_dlp/ + +The way yt-dlp works is that it has a folder called "extractor" in that path and in that folder there is a python file for each supported website. In YouTube's case it's youtube.py. I opened it and I saw this: + +``` +class YoutubeBaseInfoExtractor(InfoExtractor): + """Provide base functions for Youtube extractors""" + + _RESERVED_NAMES = ( + r'channel|c|user|playlist|watch|w|v|embed|e|live|watch_popup|clip|' + r'shorts|movies|results|search|shared|hashtag|trending|explore|feed|feeds|' + r'browse|oembed|get_video_info|iframe_api|s/player|source|' + r'storefront|oops|index|account|t/terms|about|upload|signin|logout') + + _PLAYLIST_ID_RE = r'(?:(?:PL|LL|EC|UU|FL|RD|UL|TL|PU|OLAK5uy_)[0-9A-Za-z-_]{10,}|RDMM|WL|LL|LM)' + + # _NETRC_MACHINE = 'youtube' + + # If True it will raise an error if no login info is provided + _LOGIN_REQUIRED = False + + _INVIDIOUS_SITES = ( + # invidious-redirect websites + r'(?:www\.)?redirect\.invidious\.io', + r'(?:(?:www|dev)\.)?invidio\.us', + # Invidious instances taken from https://github.com/iv-org/documentation/blob/master/docs/instances.md + r'(?:www\.)?invidious\.pussthecat\.org', + r'(?:www\.)?invidious\.zee\.li', + [more instances here] + ) +``` + +There is a class called YoutubeBaseInfoExtractor that has an array of instances called _INVIDIOUS_SITES that uses a regex to catch every domain there. Now, I saw at the GitHub page of yt-dlp a lot of people asking the maintainers to add more instances on this list. Theoretically you also can just edit the file and add a domain so that it recognizes that one too. But, in my personal opinion it's never a good idea to edit upstream files because as the program updates your changes will be overwritten. So I found another way to deal with this. + +You see, yt-dlp is not just a command line utility. You can use it as a library to make your own extractors for websites. The way you do that is by creating your own plugins. In my case, I didn't actually want to make a new extractor but somehow extend an array of an already existing one. Not all extractors use this method but since YouTube does, it would work. So I made this file at this location: + +> ~/.config/yt-dlp/plugins/piped/yt_dlp_plugins/extractor/piped.py + +The contents are simple: + +``` +from yt_dlp.extractor.youtube import YoutubeBaseInfoExtractor, YoutubeIE + +class CustomYoutubeBaseInfoExtractor(YoutubeBaseInfoExtractor): + _INVIDIOUS_SITES = YoutubeBaseInfoExtractor._INVIDIOUS_SITES + ( + r'(?:www\.)?piped\.konsthol\.eu', + ) + +class PipedKonstholYoutubeIE(YoutubeIE, CustomYoutubeBaseInfoExtractor): + _VALID_URL = r'https?://(?:www\.)?piped\.konsthol\.eu/watch\?v=(?P[0-9A-Za-z_-]{11})' + IE_NAME = 'piped.konsthol.eu' + +``` + +We import the class that contains the array we need and the youtube extractor. We make a new class in which we provide the one that has the array. We access the array and add a new regex for our domain. Then we make a new class for the extractor, provide the one we just created and the YouTube extractor class and we tell it to work for urls that look like the one we provided. In that way, this pseudo extractor is being activated when we provide a url that looks like this, it extends the actual YouTube extractor and activates that one, only this time it works for our domain too. + +It's amazing what you can do with open source software just by observing how a program works. Now every time someone needs a new domain for an alternative YouTube frontend added, instead of asking the developers to do that, using this simple solution he/she can just add it to the plugin. + +=> https://github.com/yt-dlp/yt-dlp/ yt-dlp GitHub page + +=> /cgi-bin/nimlike/show/log/simple_way_to_extend_yt_dlp-12-01-2025.gmi View likes and comments! + +=> .. diff --git a/log/simple_way_to_extend_yt_dlp-12-01-2025.html b/log/simple_way_to_extend_yt_dlp-12-01-2025.html new file mode 100644 index 0000000..1e02d31 --- /dev/null +++ b/log/simple_way_to_extend_yt_dlp-12-01-2025.html @@ -0,0 +1,151 @@ + + + + Konsthol + + + + + + + + + +
+
+

DATE: Sun 12 Jan 2025 15:51 By: konsthol@pm.me

+
+

Simple way to extend yt-dlp

+

+ Lots of people use yt-dlp either directly or indirectly through mpv. It’s a + powerful tool that acts as a website scraper and it supports thousands of + websites. The website its mostly used for is like the name suggests YouTube. + Now, YouTube is a great resource but usage through the website is quite + unpleasant so lots of people opt out to use alternative frontends like + Invidious or Piped. Lots of times you just want to use mpv to stream a YouTube + video by providing the link like: +

+
+

mpv https://youtube.com/watch?v=[VideoID]

+
+

+ That works like a charm, but what happens when you provide a link of an + alternative frontend? Well, it translates it to the aforementioned format in + order to work. But there are so many instances of Invidious and Piped, so how + does it know what to do? That was my question as well since I use a self + hosted Piped instance and it does not recognize the domain. Obviously. +

+

+ Thankfully, yt-dlp is an open source project so you can actually see what goes + on behind the scenes. In my case, I installed it with the Arch Linux package + manager and it resides at: +

+
+

/usr/lib/python3.13/site-packages/yt_dlp/

+
+

+ The way yt-dlp works is that it has a folder called “extractor” in that path + and in that folder there is a python file for each supported website. In + YouTube’s case it’s youtube.py. I opened it and I saw this: +

+
class YoutubeBaseInfoExtractor(InfoExtractor):
+    """Provide base functions for Youtube extractors"""
+
+    _RESERVED_NAMES = (
+        r'channel|c|user|playlist|watch|w|v|embed|e|live|watch_popup|clip|'
+        r'shorts|movies|results|search|shared|hashtag|trending|explore|feed|feeds|'
+        r'browse|oembed|get_video_info|iframe_api|s/player|source|'
+        r'storefront|oops|index|account|t/terms|about|upload|signin|logout')
+
+    _PLAYLIST_ID_RE = r'(?:(?:PL|LL|EC|UU|FL|RD|UL|TL|PU|OLAK5uy_)[0-9A-Za-z-_]{10,}|RDMM|WL|LL|LM)'
+
+    # _NETRC_MACHINE = 'youtube'
+
+    # If True it will raise an error if no login info is provided
+    _LOGIN_REQUIRED = False
+
+    _INVIDIOUS_SITES = (
+        # invidious-redirect websites
+        r'(?:www\.)?redirect\.invidious\.io',
+        r'(?:(?:www|dev)\.)?invidio\.us',
+        # Invidious instances taken from https://github.com/iv-org/documentation/blob/master/docs/instances.md
+        r'(?:www\.)?invidious\.pussthecat\.org',
+        r'(?:www\.)?invidious\.zee\.li',
+        [more instances here]
+    )
+

+ There is a class called YoutubeBaseInfoExtractor that has an array of + instances called _INVIDIOUS_SITES that uses a regex to catch every domain + there. Now, I saw at the GitHub page of yt-dlp a lot of people asking the + maintainers to add more instances on this list. Theoretically you also can + just edit the file and add a domain so that it recognizes that one too. But, + in my personal opinion it’s never a good idea to edit upstream files because + as the program updates your changes will be overwritten. So I found another + way to deal with this. +

+

+ You see, yt-dlp is not just a command line utility. You can use it as a + library to make your own extractors for websites. The way you do that is by + creating your own plugins. In my case, I didn’t actually want to make a new + extractor but somehow extend an array of an already existing one. Not all + extractors use this method but since YouTube does, it would work. So I made + this file at this location: +

+
+

~/.config/yt-dlp/plugins/piped/yt_dlp_plugins/extractor/piped.py

+
+

The contents are simple:

+
from yt_dlp.extractor.youtube import YoutubeBaseInfoExtractor, YoutubeIE
+
+class CustomYoutubeBaseInfoExtractor(YoutubeBaseInfoExtractor):
+    _INVIDIOUS_SITES = YoutubeBaseInfoExtractor._INVIDIOUS_SITES + (
+        r'(?:www\.)?piped\.konsthol\.eu',
+    )
+
+class PipedKonstholYoutubeIE(YoutubeIE, CustomYoutubeBaseInfoExtractor):
+    _VALID_URL = r'https?://(?:www\.)?piped\.konsthol\.eu/watch\?v=(?P<id>[0-9A-Za-z_-]{11})'
+    IE_NAME = 'piped.konsthol.eu'
+
+

+ We import the class that contains the array we need and the youtube extractor. + We make a new class in which we provide the one that has the array. We access + the array and add a new regex for our domain. Then we make a new class for the + extractor, provide the one we just created and the YouTube extractor class and + we tell it to work for urls that look like the one we provided. In that way, + this pseudo extractor is being activated when we provide a url that looks like + this, it extends the actual YouTube extractor and activates that one, only + this time it works for our domain too. +

+

+ It’s amazing what you can do with open source software just by observing how a + program works. Now every time someone needs a new domain for an alternative + YouTube frontend added, instead of asking the developers to do that, using + this simple solution he/she can just add it to the plugin. +

+

yt-dlp GitHub page

+

..

+
+
+
+ +
+ + diff --git a/log/simple_way_to_extend_yt_dlp-12-01-2025.txt b/log/simple_way_to_extend_yt_dlp-12-01-2025.txt new file mode 100644 index 0000000..3333af6 --- /dev/null +++ b/log/simple_way_to_extend_yt_dlp-12-01-2025.txt @@ -0,0 +1,128 @@ +> DATE: Sun 12 Jan 2025 15:51 By: konsthol@pm.me + +# Simple way to extend yt-dlp + +Lots of people use yt-dlp either directly or indirectly through mpv. +It's a powerful tool that acts as a website scraper and it supports +thousands of websites. The website its mostly used for is like the +name suggests YouTube. Now, YouTube is a great resource but usage +through the website is quite unpleasant so lots of people opt out to +use alternative frontends like Invidious or Piped. Lots of times you +just want to use mpv to stream a YouTube video by providing the link +like: + +> mpv https://youtube.com/watch?v=[VideoID] + +That works like a charm, but what happens when you provide a link of +an alternative frontend? Well, it translates it to the aforementioned +format in order to work. But there are so many instances of Invidious +and Piped, so how does it know what to do? That was my question as +well since I use a self hosted Piped instance and it does not +recognize the domain. Obviously. + +Thankfully, yt-dlp is an open source project so you can actually see +what goes on behind the scenes. In my case, I installed it with the +Arch Linux package manager and it resides at: + +> /usr/lib/python3.13/site-packages/yt_dlp/ + +The way yt-dlp works is that it has a folder called "extractor" in +that path and in that folder there is a python file for each +supported website. In YouTube's case it's youtube.py. I opened it and +I saw this: + + +class YoutubeBaseInfoExtractor(InfoExtractor): + """Provide base functions for Youtube extractors""" + + _RESERVED_NAMES = ( + +r'channel|c|user|playlist|watch|w|v|embed|e|live|watch_popup|clip|' + +r'shorts|movies|results|search|shared|hashtag|trending|explore|feed|fe +eds|' + r'browse|oembed|get_video_info|iframe_api|s/player|source|' + +r'storefront|oops|index|account|t/terms|about|upload|signin|logout') + + _PLAYLIST_ID_RE = +r'(?:(?:PL|LL|EC|UU|FL|RD|UL|TL|PU|OLAK5uy_)[0-9A-Za-z-_]{10,}|RDMM|WL +|LL|LM)' + + # _NETRC_MACHINE = 'youtube' + + # If True it will raise an error if no login info is provided + _LOGIN_REQUIRED = False + + _INVIDIOUS_SITES = ( + # invidious-redirect websites + r'(?:www\.)?redirect\.invidious\.io', + r'(?:(?:www|dev)\.)?invidio\.us', + # Invidious instances taken from +https://github.com/iv-org/documentation/blob/master/docs/instances.md + r'(?:www\.)?invidious\.pussthecat\.org', + r'(?:www\.)?invidious\.zee\.li', + [more instances here] + ) + + +There is a class called YoutubeBaseInfoExtractor that has an array of +instances called _INVIDIOUS_SITES that uses a regex to catch every +domain there. Now, I saw at the GitHub page of yt-dlp a lot of people +asking the maintainers to add more instances on this list. +Theoretically you also can just edit the file and add a domain so +that it recognizes that one too. But, in my personal opinion it's +never a good idea to edit upstream files because as the program +updates your changes will be overwritten. So I found another way to +deal with this. + +You see, yt-dlp is not just a command line utility. You can use it as +a library to make your own extractors for websites. The way you do +that is by creating your own plugins. In my case, I didn't actually +want to make a new extractor but somehow extend an array of an +already existing one. Not all extractors use this method but since +YouTube does, it would work. So I made this file at this location: + +> ~/.config/yt-dlp/plugins/piped/yt_dlp_plugins/extractor/piped.py + +The contents are simple: + + +from yt_dlp.extractor.youtube import YoutubeBaseInfoExtractor, +YoutubeIE + +class CustomYoutubeBaseInfoExtractor(YoutubeBaseInfoExtractor): + _INVIDIOUS_SITES = YoutubeBaseInfoExtractor._INVIDIOUS_SITES + ( + r'(?:www\.)?piped\.konsthol\.eu', + ) + +class PipedKonstholYoutubeIE(YoutubeIE, +CustomYoutubeBaseInfoExtractor): + _VALID_URL = +r'https?://(?:www\.)?piped\.konsthol\.eu/watch\?v=(?P[0-9A-Za-z_-] +{11})' + IE_NAME = 'piped.konsthol.eu' + + + +We import the class that contains the array we need and the youtube +extractor. We make a new class in which we provide the one that has +the array. We access the array and add a new regex for our domain. +Then we make a new class for the extractor, provide the one we just +created and the YouTube extractor class and we tell it to work for +urls that look like the one we provided. In that way, this pseudo +extractor is being activated when we provide a url that looks like +this, it extends the actual YouTube extractor and activates that one, +only this time it works for our domain too. + +It's amazing what you can do with open source software just by +observing how a program works. Now every time someone needs a new +domain for an alternative YouTube frontend added, instead of asking +the developers to do that, using this simple solution he/she can just +add it to the plugin. + +yt-dlp GitHub page +https://github.com/yt-dlp/yt-dlp/ + + + diff --git a/log_archive.gmi b/log_archive.gmi index 57b971e..c399f35 100644 --- a/log_archive.gmi +++ b/log_archive.gmi @@ -3,6 +3,10 @@ Previous Log entries are archived here. # Logs +## 2025 + +=> /log/simple_way_to_extend_yt_dlp-12-01-2025.gmi 12-01-2025 - Simple way to extend yt-dlp + ## 2024 => /log/the_magic_of_wake_on_lan-19-12-2024.gmi 19-12-2024 - The magic of Wake-On-LAN diff --git a/log_archive.html b/log_archive.html index 7c17a6c..aa15b71 100644 --- a/log_archive.html +++ b/log_archive.html @@ -33,21 +33,27 @@

ALL Log Posts - The Archive

Previous Log entries are archived here.

Logs

-

2024

+

2025

+

+ 12-01-2025 - Simple way to extend yt-dlp
+

+

2024

19-12-2024 - The magic of Wake-On-LAN

-

2023

+

2023

25-02-2023 - WebCall

-

2022

+

2022

17-08-2022 - wpgtk is just more convenient

-

2021

+

2021

12-09-2021 - Awesome file sharing toolhttps://konsthol.eu/rss.xml + +Simple way to extend yt-dlp +https://konsthol.eu/log/simple_way_to_extend_yt_dlp-12-01-2025.html +Sun, 12 Jan 2025 + +

DATE: Sun 12 Jan 2025 15:51 By: konsthol@pm.me

+ +

Simple way to extend yt-dlp

+

+ Lots of people use yt-dlp either directly or indirectly through mpv. It’s a + powerful tool that acts as a website scraper and it supports thousands of + websites. The website its mostly used for is like the name suggests YouTube. + Now, YouTube is a great resource but usage through the website is quite + unpleasant so lots of people opt out to use alternative frontends like + Invidious or Piped. Lots of times you just want to use mpv to stream a YouTube + video by providing the link like: +

+
+

mpv https://youtube.com/watch?v=[VideoID]

+
+

+ That works like a charm, but what happens when you provide a link of an + alternative frontend? Well, it translates it to the aforementioned format in + order to work. But there are so many instances of Invidious and Piped, so how + does it know what to do? That was my question as well since I use a self + hosted Piped instance and it does not recognize the domain. Obviously. +

+

+ Thankfully, yt-dlp is an open source project so you can actually see what goes + on behind the scenes. In my case, I installed it with the Arch Linux package + manager and it resides at: +

+
+

/usr/lib/python3.13/site-packages/yt_dlp/

+
+

+ The way yt-dlp works is that it has a folder called “extractor” in that path + and in that folder there is a python file for each supported website. In + YouTube’s case it’s youtube.py. I opened it and I saw this: +

+
class YoutubeBaseInfoExtractor(InfoExtractor):
+    """Provide base functions for Youtube extractors"""
+
+    _RESERVED_NAMES = (
+        r'channel|c|user|playlist|watch|w|v|embed|e|live|watch_popup|clip|'
+        r'shorts|movies|results|search|shared|hashtag|trending|explore|feed|feeds|'
+        r'browse|oembed|get_video_info|iframe_api|s/player|source|'
+        r'storefront|oops|index|account|t/terms|about|upload|signin|logout')
+
+    _PLAYLIST_ID_RE = r'(?:(?:PL|LL|EC|UU|FL|RD|UL|TL|PU|OLAK5uy_)[0-9A-Za-z-_]{10,}|RDMM|WL|LL|LM)'
+
+    # _NETRC_MACHINE = 'youtube'
+
+    # If True it will raise an error if no login info is provided
+    _LOGIN_REQUIRED = False
+
+    _INVIDIOUS_SITES = (
+        # invidious-redirect websites
+        r'(?:www\.)?redirect\.invidious\.io',
+        r'(?:(?:www|dev)\.)?invidio\.us',
+        # Invidious instances taken from https://github.com/iv-org/documentation/blob/master/docs/instances.md
+        r'(?:www\.)?invidious\.pussthecat\.org',
+        r'(?:www\.)?invidious\.zee\.li',
+        [more instances here]
+    )
+

+ There is a class called YoutubeBaseInfoExtractor that has an array of + instances called _INVIDIOUS_SITES that uses a regex to catch every domain + there. Now, I saw at the GitHub page of yt-dlp a lot of people asking the + maintainers to add more instances on this list. Theoretically you also can + just edit the file and add a domain so that it recognizes that one too. But, + in my personal opinion it’s never a good idea to edit upstream files because + as the program updates your changes will be overwritten. So I found another + way to deal with this. +

+

+ You see, yt-dlp is not just a command line utility. You can use it as a + library to make your own extractors for websites. The way you do that is by + creating your own plugins. In my case, I didn’t actually want to make a new + extractor but somehow extend an array of an already existing one. Not all + extractors use this method but since YouTube does, it would work. So I made + this file at this location: +

+
+

~/.config/yt-dlp/plugins/piped/yt_dlp_plugins/extractor/piped.py

+
+

The contents are simple:

+
from yt_dlp.extractor.youtube import YoutubeBaseInfoExtractor, YoutubeIE
+
+class CustomYoutubeBaseInfoExtractor(YoutubeBaseInfoExtractor):
+    _INVIDIOUS_SITES = YoutubeBaseInfoExtractor._INVIDIOUS_SITES + (
+        r'(?:www\.)?piped\.konsthol\.eu',
+    )
+
+class PipedKonstholYoutubeIE(YoutubeIE, CustomYoutubeBaseInfoExtractor):
+    _VALID_URL = r'https?://(?:www\.)?piped\.konsthol\.eu/watch\?v=(?P<id>[0-9A-Za-z_-]{11})'
+    IE_NAME = 'piped.konsthol.eu'
+
+

+ We import the class that contains the array we need and the youtube extractor. + We make a new class in which we provide the one that has the array. We access + the array and add a new regex for our domain. Then we make a new class for the + extractor, provide the one we just created and the YouTube extractor class and + we tell it to work for urls that look like the one we provided. In that way, + this pseudo extractor is being activated when we provide a url that looks like + this, it extends the actual YouTube extractor and activates that one, only + this time it works for our domain too. +

+

+ It’s amazing what you can do with open source software just by observing how a + program works. Now every time someone needs a new domain for an alternative + YouTube frontend added, instead of asking the developers to do that, using + this simple solution he/she can just add it to the plugin. +

+

yt-dlp GitHub page

+

..

]]> + + + The magic of Wake-On-LAN https://konsthol.eu/log/the_magic_of_wake_on_lan-19-12-2024.html