Use original YouTube thumbnails on your YouTube video imports

I have started downloading some YT videos that are cooking show related for the wife.

I am looking into this utility and realized I already have a lot of downloaded videos and don't have the required naming in the title. Is there a utility that you guys know of that would do that?

What are you using that downloads with the correct naming syntax? I have been using Media Human but it doesn't look like that is one of the options in their software that I can find.

1 Like

Thank you so much! I had missed that advanced button when I had the UI opened up.

So, I am not a programmer, but thought this script may be easy to run and try my hand at it. I downloaded and installed Ruby on my DVR server (windows 11 machine), copied the script into a text file with .rb extension and saved in a folder on my hdd, added my DVR URL where indicated in the script.

When I run the script I get this error: internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:88:in require': cannot load such file -- httparty (LoadError) from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in require'
from fix_thumbnails.rb:1:in `'

I tried to google the "cannot load such file -- httparty (LoadError) but I can't seem to find anything that I understand.

Is this just some simple thing I am missing or am I out of my depth here and it's not as easy as I thought?

2 Likes

You need to install that package with the rubygems package manager.

I don’t know anything about ruby on windows, but on Unix you would run this at the command line:

gem install httparty

Maybe this is enough to help you google how to do it in windows.

1 Like

Thanks! That handled that error. In Windows, it does run in the command prompt.

Anyway, now I get the error: fix_thumbnails.rb:7:in `': uninitialized constant Youtube (NameError)

source_files = HTTParty.get("#{server_url}/dvr/groups/#{Youtube}/files")

So I assume I am not filling in something correctly somewhere in the script, but not sure what I am supposed to put there, if anything.

1 Like

You edited that part of the script. Edit the above variable video_group to be the video group ID you want to manipulate in your Channels library.

It will be a long collections of letter and numbers. You can get it by visiting this group in your web admin and getting it from the url.

2 Likes

Awesome! Thanks.

It does run without throwing any errors in the command line. However, it's doesn't change any of the images or the title. I am trying to figure out where to find an error log to look at but haven't yet.

1 Like

I figured out what I was doing incorrectly! When I put the video group number in the video_group line in the script I wasn't adding the "video-" part before the collection of letters and numbers. Adding that made it work perfectly!

Thanks for this little script! It makes a real difference in my videos section.

@Fofer - were you successful using this to pull in the Summary information?

package = {Thumbnail: yt_thumbnail_url, Airing: {EpisodeTitle: new_title, Summary: new_summary, FullSummary: new_full_summary}}

1 Like

Will this work with movies and tv shows purchased from YouTube?

This topic is about updating metadata of imported videos.

I wasn’t. But I only tried once, didn't put a lot of time into it. I’m guessing you weren’t either?

Those videos have Widevine DRM copyright protection so wouldn't be importable/playable in Channels DVR anyway.

No, wasn't able to have it work here - I suspect I need something earlier in the script like he has "title = file['Airing']['EpisodeTitle']" but I am not a programmer so I don't always know what to put where.

I did add "package = {Thumbnail: yt_thumbnail_url, Airing: {EpisodeTitle: new_title, Summary: new_summary, FullSummary: new_full_summary}}" but that alone produces some errors when I run the script.

I didn't want to bother @maddox with all my silly questions (hint, hint) :grinning:

1 Like

How would this be adapted to run on macOS?

No adapting needed, Ruby runs on Mac too. It can get a little complicated though if you don't know what you're doing. These pages provide interesting resources, may prove useful:

https://www.ruby-lang.org/en/documentation/installation/#homebrew

A little above my pay grade but thanks for sharing. I was hoping for a simple way to retain the original YouTube thumbnail images but this method seems a bit too complex for me. Bummer…

I decided to take a stab at this, however after running the script on MacOS, I get the following “test.rb:1: syntax error, unexpected backslash, expecting '}'
{\rtf1\ansi\ansicpg1252\cocoart...”.

My Ruby script is:

require 'httparty'
require 'json'

server_url = 'http://192.168.1.100:8089'
video_group = 'VIDEO_GROUP_ID'

source_files = HTTParty.get("#{server_url}/dvr/groups/#{video_group}/files")

source_files.each do |file|
file_id = file['ID']
title = file['Airing']['EpisodeTitle']
yt_match = title.match(/(((\d\d\d\d-\d\d-\d\d)))??[(.*)]/)

if yt_match
yt_date = yt_match[2]
yt_id = yt_match[3]
yt_thumbnail_url = "https://i3.ytimg.com/vi/#{yt_id}/maxresdefault.jpg"
new_title = title.gsub(yt_match[0], '')

package = {Thumbnail: yt_thumbnail_url, Airing: {EpisodeTitle: new_title}}

if yt_date
  package[:Airing][:OriginalDate] = yt_date
end

HTTParty.put("#{server_url}/dvr/files/#{file_id}", :body => package.to_json)

end
end

Any thoughts?

It sounds like you pasted into TextEdit and saved as rtf instead of plain text

1 Like

Yep, I think it’s working now because I’m not getting any errors when I run the script, however I don’t see any changes being made to the video files.

Here is an example of the naming convention I’m using, is this correct?
EVERY New Feature Rumored for iOS 17, watchOS 10, macOS 14, & More at WWDC 2023!_2023-05-17_pCxubfuRn7U