Self hosted Youtube URL shortener and QR generator
During holidays I take pictures and sometimes make a video. Sometimes I make a photo album. I wanted to add small working QR codes to the photo album so I can see relevant videos.
I wrote this for my own use so it is not tested except for my Raspbian (currently Bookworm) using Firefox on Windows.
- Have (sub)domainname control and ownership
- Videos are currently hosted at Youtube for which credentials are available
- Album will be printed only once and must not be reprinted
- QR code target can be repaired when Youtube changes the URL
- QR code target can be repaired when Youtube removes URL
- QR code target can be repaired when another supplier is chosen for hosting videos
- QR codes should be small and be only a minor part in a photo album page, like a foot note
- It should be clear for which video the QR code is generated
- It should be easy to create and download 100 QR codes within an hour
I wrote an interface that:
- Generates an overview of all your Youtube playlists
- List all items of a selected Youtube playlist
- Allows you to preview the video
- Generate a unique redirect (short) URL for your selected domainname
- Generate a QRCode for the unique URL
- Copy config.php.example to config.php and modify to your needs
- Install https://github.com/googleapis/google-api-php-client
- Create OAuth 2.0 Client ID for Web application credentials on https://console.cloud.google.com for youtube.api.v3.V3DataPlaylistItemService.List and youtube.api.v3.V3DataPlaylistService.List
- Run getRefreshToken.php and follow instructions (you might have to do this every once in a while since it might expire)
- Go to https://example.org/v/ytqr.html
- Click white blocks at the right bottom of the video
- Download QR codes
- Add to photo album
- Test photo album and enjoy!
- Project code except for qrcode.js - by Gerben Versluis distributed under LICENSE
- QR Code Generator for JavaScript by Kazuhiko Arase - Very good javascript based QR code generator MIT license
- Google API PHP client by The googleapis organization - Overkill of files generated by Google to do a few simple API calls Apache 2.0 license