From 7ae34f3ef0efb296715fdab2d7c115b75ccc5db4 Mon Sep 17 00:00:00 2001 From: Daniel Duggin <46377670+danielduggin2@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:50:09 -0500 Subject: [PATCH] Added YouTube documentation --- user/plugins/fix-youtube-titles/LICENSE | 21 ++++++++++++ user/plugins/fix-youtube-titles/README.md | 28 ++++++++++++++++ user/plugins/fix-youtube-titles/plugin.php | 37 ++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 user/plugins/fix-youtube-titles/LICENSE create mode 100644 user/plugins/fix-youtube-titles/README.md create mode 100644 user/plugins/fix-youtube-titles/plugin.php diff --git a/user/plugins/fix-youtube-titles/LICENSE b/user/plugins/fix-youtube-titles/LICENSE new file mode 100644 index 0000000..3a45f61 --- /dev/null +++ b/user/plugins/fix-youtube-titles/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2013-present, The YOURLS Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/user/plugins/fix-youtube-titles/README.md b/user/plugins/fix-youtube-titles/README.md new file mode 100644 index 0000000..1210ff2 --- /dev/null +++ b/user/plugins/fix-youtube-titles/README.md @@ -0,0 +1,28 @@ +# Fix Youtube titles [![Listed in Awesome YOURLS!](https://img.shields.io/badge/Awesome-YOURLS-C5A3BE)](https://github.com/YOURLS/awesome-yourls/) + +_Without this plugin_, shortening a Youtube URL returns an incorrect title: Before you continue to YouTube (read why below) + +**With this plugin**, you get the correct title, ie Backyard Squirrel Maze 1.0- Ninja Warrior Course - YouTube + +Tested with [YOURLS](https://yourls.org) `1.8.1` and above. + +## Installation + +1. In `/user/plugins`, create a new folder named `fix-youtube-titles` or something like this +2. Drop these files in that directory. +3. Go to the Plugins administration page (eg. `http://sho.rt/admin/plugins.php`) and activate the plugin. +4. Have fun! + +## License + +Do what the hell you want with it. + +## Why is this needed? + +Youtube redirects every unknown user to a page where they need to accept their darn cookies: + + + +Your YOURLS instance is such an _unknown_ user to Google, since it has no Youtube cookie. This plugin tricks Youtube and makes it think it has one. + +🍪 FTW. diff --git a/user/plugins/fix-youtube-titles/plugin.php b/user/plugins/fix-youtube-titles/plugin.php new file mode 100644 index 0000000..7eaa4fe --- /dev/null +++ b/user/plugins/fix-youtube-titles/plugin.php @@ -0,0 +1,37 @@ + 0 ) { + // change user agent to "curl". Actually, this is enough to trick Youtube ¯\_(ツ)_/¯ + yourls_add_filter('http_user_agent', function(){return 'curl/7.68.0';}); + + // The