geerlingguy / jeffgeerling-com

Drupal Codebase for JeffGeerling.com
https://www.jeffgeerling.com
GNU General Public License v2.0
41 stars 2 forks source link

Add latest YouTube video block to home page #137

Open geerlingguy opened 2 years ago

geerlingguy commented 2 years ago

I'd like to have a custom block which displays a video thumbnail, then title, then date, for the three most recent YouTube videos on my channel. There's gotta be some simple API I could use to get this to automatically pull in. Set a cache on the block so it generates once every hour or so, and bob's your uncle!

TechStudent10 commented 2 years ago

Not sure if this is too late but I found this on Stack Overflow; https://stackoverflow.com/a/23253789

All that's left is getting the latest video ID.

minecraftchest1 commented 2 years ago

This script gets the video ID and name using yt-dlp if you are intersted. That would allow you to link directly to the video if you want. yt-dlp spits out other information that could be useful. Then the only thing would be figuring how to update the homepage with that info.

yt-dlp --playlist-items 1 --skip-download --dump-json  'https://www.youtube.com/c/JeffGeerling' | jq '.id, .title'

Some other fields that might be useful

"webpage_url",
"upload_date",
"view_count".
"categories[]",
"categories[]",
"like_count",
"fulltitle",
"width",
"height",
"resolution",
"thumbnail",
"description",
TechStudent10 commented 2 years ago

This script gets the video ID and name using yt-dlp if you are intersted. That would allow you to link directly to the video if you want. yt-dlp spits out other information that could be useful. Then the only thing would be figuring how to update the homepage with that info.

yt-dlp --playlist-items 1 --skip-download --dump-json  'https://www.youtube.com/c/JeffGeerling' | jq '.id, .title'

Some other fields that might be useful

"webpage_url",
"upload_date",
"view_count".
"categories[]",
"categories[]",
"like_count",
"fulltitle",
"width",
"height",
"resolution",
"thumbnail",
"description",

Isn't that a CLI tool?

minecraftchest1 commented 2 years ago

Yes.

Wyatt Jackson Matrix: @minecraftchest1:matrix.org Discord: Minecraftchest1#8670 Telegram: https://t.me/minecraftchest1 Mastodon: @@. Github: https://github.com/minecraftchest1 Gitlab: https://gitlab.com/minecraftchest1 Email: @.

Sent from my T-Mobile 4G LTE Device

-------- Original message -------- From: TechStudent10 @.> Date: 2/12/22 2:25 PM (GMT-06:00) To: geerlingguy/jeffgeerling-com @.> Cc: Minecraftchest1 @.>, Comment @.> Subject: Re: [geerlingguy/jeffgeerling-com] Add latest YouTube video block to home page (Issue #137)

This script gets the video ID and name using yt-dlp if you are intersted. That would allow you to link directly to the video if you want. yt-dlp spits out other information that could be useful. Then the only thing would be figuring how to update the homepage with that info.

yt-dlp --playlist-items 1 --skip-download --dump-json 'https://www.youtube.com/c/JeffGeerling' | jq '.id, .title'

Some other fields that might be useful

"webpage_url", "upload_date", "view_count". "categories[]", "categories[]", "like_count", "fulltitle", "width", "height", "resolution", "thumbnail", "description",

Isn't that a CLI tool?

— Reply to this email directly, view it on GitHubhttps://github.com/geerlingguy/jeffgeerling-com/issues/137#issuecomment-1037453034, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKIAII5BWKY3Z7I2FV5TRF3U226ZVANCNFSM5KRSFQPA. You are receiving this because you commented.Message ID: @.***>

TechStudent10 commented 2 years ago

Yes.

And this is a website

minecraftchest1 commented 2 years ago

Yes it is a command line tool. Yes, we are talking about content on a website. However, this website we are talking about has a way to update content through some sort of API. I imagine it would not be hard to have a script run the command out of a cron job and update the page using curl. If not, a plugin could likely also be written to run the command on the server. There is also the possibility of using an iframe or something similar to embed a page that shows the video or other info using a page rendered using CGI, go webapp, python webapp, nodejs webapp, etc. The Json output could also be saved to a file accessable to the public updated by a cron job and accessed by a plugin or via client side javascript.

TechStudent10 commented 2 years ago

Yes it is a command line tool. Yes, we are talking about content on a website. However, this website we are talking about has a way to update content through some sort of API. I imagine it would not be hard to have a script run the command out of a cron job and update the page using curl. If not, a plugin could likely also be written to run the command on the server. There is also the possibility of using an iframe or something similar to embed a page that shows the video or other info using a page rendered using CGI, go webapp, python webapp, nodejs webapp, etc. The Json output could also be saved to a file accessable to the public updated by a cron job and accessed by a plugin or via client side javascript.

Yeah, I guess that works

TechStudent10 commented 2 years ago

Yes it is a command line tool. Yes, we are talking about content on a website. However, this website we are talking about has a way to update content through some sort of API. I imagine it would not be hard to have a script run the command out of a cron job and update the page using curl. If not, a plugin could likely also be written to run the command on the server. There is also the possibility of using an iframe or something similar to embed a page that shows the video or other info using a page rendered using CGI, go webapp, python webapp, nodejs webapp, etc. The Json output could also be saved to a file accessable to the public updated by a cron job and accessed by a plugin or via client side javascript.

Yeah, I guess that works