Closed tfabris closed 5 months ago
Update: I was able to find a setting in the default channel settings. Go to https://studio.youtube.com/ and press SETTINGS in the lower left corner. Press UPLOAD DEFAULTS and then press ADVANCED SETTINGS. This gets you to the default setting for "Category". With this configured I don't think we need to automate the "Category", I believe it's a set-once-and-forget setting.
Still investigating "Playlists".
Update: Wait a minute. I still need to fix the "Category" getting clobbered every time that a new liveStream object is created. Despite the default settings described in the prior comment, it still comes up as "Entertainment" each time a new (not previously used) liveStream object is created.
Status:
To get the list of all possible category IDs in your country, you have to use the VidoeCategories: list function, with the parameters part=snippet®ionCode=US
where the "US" part is your desired region code from the standard two-letter region codes like the ones listed here.
Here is the list for the "US" regionCode: 1 Film & Animation 2 Autos & Vehicles 10 Music 15 Pets & Animals 17 Sports 18 Short Movies 19 Travel & Events 20 Gaming 21 Videoblogging 22 People & Blogs 23 Comedy 24 Entertainment 25 News & Politics 26 Howto & Style 27 Education 28 Science & Technology 29 Nonprofits & Activism 30 Movies 31 Anime/Animation 32 Action/Adventure 33 Classics 34 Comedy 35 Documentary 36 Drama 37 Family 38 Foreign 39 Horror 40 Sci-Fi/Fantasy 41 Thriller 42 Shorts 43 Shows 44 Trailers
To do:
Updating the categoryId from the API explorer works, now I just need to implement it in code. You must use "part=snippet" and the BODY DATA of the request (not the parameters) contains the ID of the video that you want to update. You must update both the title and the cateogryID, those happen to be the minimum things. Also it must be a PUT operation. Like this:
PUT https://youtube.googleapis.com/youtube/v3/videos?part=snippet
{
"id": "icdhnUth9XY",
"snippet":
{
"title": "CrowCam",
"categoryId": "15"
}
}
The response is a video resource, with part=snippet, and the field updated.
Adding to the playlist works (I have to fix the ordering position, it oddly doesn't default to the top), but writing the "snippet" with just those two items, it CLOBBERS every other item in the snipped, like Description and Tags. ARGH! Need to fix that before I can put this code into action.
Fixed with checkin dac2b13 - Youtube has a bug where when you fix the categoryId by sending a "Snippet" to the video, even if your snippet is only populated with the minimum fields (Title and CategoryID), it clobbers the entire rest of the snippet! That means that Description, Tags, and Thumbnail are overwritten. This is awful. Work around this issue by adding default Description, Tags, and Thumbnail directly into the sources and write all that stuff to the video, including uploading a new Thumbnail JPG every fscking time. Wow YouTube makes it so hard.
Adding to the playlist works as expected: You have to open up the playlist and then add the video to the playlist (not the other way around), and you must add it at position: 0 in order to float it to the top. This incidentally also fixes bug #78 which is a nice bonus.
There is existing code in CrowCam.sh for fixing the following things if they are changed:
If the Stream Key changes, that's actually a situation where a whole new broadcast had to be created. Some of the settings are lost in that case. Most of the stuff is copied over from your last livestream (luckily things like the text description seem to be kept), but I have noticed that the following things will change each time, and need to be fixed like the Visibility is currently getting fixed:
See later comment: I found the general setting for Category so it doesn't need to be automated.Reinstated - this still needs to be fixed.