set a video's game using youtube data api - youtube

I am looking for a way to programatically set a video's game. By "game" I mean the video setting that makes these things appear in the video's description:
I can set and read the category using the categoryId field, e.g. "20" for Gaming. But I was unable to find any official way to set some kind of game id.
The Youtube Studio seems to perform this action to achieve the goal (shortened):
POST https://studio.youtube.com/youtubei/v1/video_manager/metadata_update
{
"encryptedVideoId": "UEUN1xD6BFI",
"videoReadMask": {...},
"gameTitle": {
"newKgEntityId": "/g/11gfhqhs78"
},
"context": {...}
}
And it uses something called SAPISIDHASH for authorization, which some people seem to have reverse-engineered, but before I even try to do that I wanted to see if there's an official supported way of doing this.

No ! There is not any supported way to do this as I know, an old friend of mine used the SAPISIDHASHmethod, and that was working like a charm, maybe a day they will open this for everyone

Related

Programmatically search Youtube videos and return the first available one on a web page

Good day!
Let's say I have a web page dedicated to a specific song by a specific author (eg "Imagine" by "John Lennon"). I would like to programmatically:
Search Youtube for the first n videos with "Imagine John Lennon"
Loop through these results to find a video which is available in the country where the user is located
Display the first video that matches the constraints on point 2. If no video matches them, then I won't display any video.
How can I do this? Is it better to do it with PHP or Ajax calls? I already checked some similar questions (1, 2) but as they are "old" I was wondering if there is a better method now.
Thanks for any help
This can be done with a single call to the Search: list endpoint, setting the 'q' and 'regionCode' parameters. Use any programming language you prefer.

Search iTunes for podcast by title

I'd like to find the specific podcast episode titled "#1: The Single White Guy Focus Group." According to the iTunes search API, I believe I should be able to find it with the following:
https://itunes.apple.com/search?term=%231:+The+Single+Straight+Guy+Focus+Group&entity=podcast&attribute=keywordsTerm
But that returns an empty JSON. I also tried
https://itunes.apple.com/search?term=The+Single+Straight+Guy+Focus+Group&entity=podcast
... and ...
https://itunes.apple.com/search?term=The+Single+Straight+Guy+Focus+Group
... but I always get the same result.
{
"resultCount":0,
"results": []
}
I'm baffled. I know the episode is in there - here it is.
https://itunes.apple.com/us/podcast/1-single-straight-guy-focus/id775053292?i=1000375469754&mt=2
(posting full url so deliberately, so you can see that indeed there is a url which does point to that specific episode)
So why can't I find it?
EDIT: Note that I am doing this in an Obj-C iOS app, in case that is relevant.
After a TON of hair-pulling, I've found that there is an undocumented entity (podcastEpisode) that does what we all want.
So, on the off-chance the original poster is still at this after 3 years (or more likely other frustrated folks like myself browsing) - try this (using the original example):
https://itunes.apple.com/search?term=The+Single+Straight+Guy+Focus+Group&entity=podcastEpisode
Unfortunately apple API searches only by the title of the podcast and not by the title of the episode. I'm trying to add a search by episode on my app but to no avail so far

Stream Audio from AWS to Rails App Using Fog/Carrierwave

I have a Rails app that lets a user upload an mp3 to their Profile model and then stores it with AWS S3. I am trying to figure out how to make a connection via Fog and stream their song when it's clicked, similar to the functionality of Soundcloud or Bandcamp. I have been looking at the Fog docs and similar posts, but am stuck. I think I have to use send_file, but am not sure. Any info would be greatly appreciated. I plan on using jplayer or something similar to actually play the audio, just need to make that connection happen on click.
UPDATE:
I am currently trying to implement something to this effect in my Profile controller, follwing this doc http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/Bucket.html
bucket = s3.buckets.create('name', :grants => {
:grant_read => [
{ :uri => "http://acs.amazonaws.com/groups/global/AllUsers" },
],
:grant_full_control => [
{ :id => 'abc...mno' } # cannonical user id
{ :email_address => 'foo#bar.com' }, # email address
]
})
In my view I have the following, just so I have something to look at and work with.
<audio id="song" class="audio_player" controls="false" preload="true">
<source src="/audios/ignite.mp3" type="audio/mpeg">
</audio>
So there is a disconnect here, kind of feel like I am taking shots in the dark. I think a little bit of clarity will put me on the right track. I have also unsuccessfully gotten Fog to work in my console, which would help things, but is a separate thread. Thank you for any help.
I suspect you won't actually want to stream the audio through your server. It would probably be better to just have the source attribute there point directly at s3. You have a couple options there. First, since you appear to have it set to public readability, you can just link directly to the url (I believe carrierwave has methods to give you this url). You could also do this without public read by using signed/expiring urls, but that gets a bit more complicated.
All that said, if it is really important that it appear to be coming from your server (instead of S3), you may want to look in to setting up a CNAME to S3 so that it is still being served from there, but will appear to come from a subdomain of your host (or similar). Hope that helps to point you in the right direction, but let me know otherwise and I can try to add further specificity. Thanks!

Get the music genres in YouTube

When we view the YouTube page, and click Music, we are able to see them on different genre's like "Rap", "Rock", "Country", etc.
How can I retrieve this data (the genre-wise listing of videos) using the YouTube Apis.?
One way to do this is using the Topics API integration with V3 of the API. Take a look at the videos.list() API call. Plug in these values:
part: topicDetails
id: fWNaR-rxAic
fields: items/topicDetails/topicIds
The ID of that video corresponds to Carly Rae Jepsen's "Call Me Maybe". When you look at the JSON response, you'll see a list of topic IDs:
[ "/m/015f7",
"/m/0h55y27",
"/m/0gkxzs6",
"/m/064t9" ]
These are Freebase machine IDs. You would then make a Freebase API call to retrieve information about that particular topic. For instance, /m/064t9 corresponds to "Pop Music".
Thise method won't work for 100% of videos on YouTube; Metallica's "Whiskey in a Jar" only returns topics for the song and the band, however, Britney Spear's "I Want to Go" correctly returns a machine ID for "Pop Music".
The reason for this is that the Topic is often machine generated, not human curated (though we do quality checks). We did a Google I/O talk about how this works. The good news is that once you DO have a machine ID, it's very easy to find other videos by topic ID. Our samples demonstrate how to do this.
In freebase you can ask for music genre mids. For example in: http://www.freebase.com/search?query=rock you get that /m/06by7 = rock. With this id you do a query on youtube and get videos regarding this genre;
Try it https://developers.google.com/youtube/v3/docs/search/list#try-it with this conditions:
part: snippet
topicId: /m/06by7
For anyone wondering about this now (2017) freebase is deprecated and so instead you should use the list currently provided here: https://gist.github.com/stpe/2951130dfc8f1d0d1a2ad736bef3b703
Ikai Lan is still correct that the part is topicDetails to get this information from the API.

How to customize an end time for a YouTube video?

I'm trying to figure out how I can specify a custom end time for an embedded YouTube video. I know that I can customize the start time by adding &start=30, but I haven't seen anything relating to the end time.
I need to be able to do this for a web app I'm building, so if there is no way provided by YouTube, how might I be able to accomplish this anyway?
I've skimmed over the documentation to no avail. Thanks!
I just found out that the following works:
https://www.youtube.com/embed/[video_id]?start=[start_at_second]&end=[end_at_second]
Note: the time must be an integer number of seconds (e.g. 119, not 1m59s).
I tried the method of #mystic11 ( https://stackoverflow.com/a/11422551/506073 ) and got redirected around. Here is a working example URL:
http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3
If the version=3 parameter is omitted, the video starts at the correct place but runs all the way to the end. From the documentation for the end parameter I am guessing version=3 asks for the AS3 player to be used. See:
end (supported players: AS3, HTML5)
Additional Experiments
Autoplay
Autoplay of the clipped video portion works:
http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&autoplay=1
Looping
Adding looping as per the documentation unfortunately starts the second and subsequent iterations at the beginning of the video:
http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&loop=1&playlist=WA8sLsM3McU
To do this properly, you probably need to set enablejsapi=1 and use the javascript API.
FYI, the above video looped: http://www.infinitelooper.com/?v=WA8sLsM3McU&p=n#/15;19
Remove Branding and Related Videos
To get rid of the Youtube logo and the list of videos to click on to at the end of playing the video you want to watch, add these (&modestBranding=1&rel=0) parameters:
http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&autoplay=1&modestBranding=1&rel=0
Remove the uploader info with showinfo=0:
http://youtube.googleapis.com/v/WA8sLsM3McU?start=15&end=20&version=3&autoplay=1&modestBranding=1&rel=0&showinfo=0
This eliminates the thin strip with video title, up and down thumbs, and info icon at the top of the video. The final version produced is fairly clean and doesn't have the downside of giving your viewers an exit into unproductive clicking around Youtube at the end of watching the video portion that you wanted them to see.
Use parameters(seconds) i.e. youtube.com/v/VIDEO_ID?start=4&end=117
Live DEMO:
https://puvox.software/software/youtube_trimmer.php
Youtube doesn't provide any option for an end time, but there alternative sites that provide this, like
Tubechop. Otherwise try writing a function that either pauses video/skips to next
when your when your video has played its desired duration.
OR: using the Youtube Javascript player API, you could do something like this:
function onPlayerStateChange(evt) {
if (evt.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
Youtube API blog
Today I found, that the old ways are not working very well.
So I used:
"Customize YouTube Start and End Time - Acetrot.com"
from http://www.youtubestartend.com/
They provide a link into
https://xxxx.app.goo.gl/yyyyyyyyyy
e.g. https://v637g.app.goo.gl/Cs2SV9NEeoweNGGy9
Link contain forward to format like this
https://www.youtube.com/embed/xyzabc123?start=17&end=21&version=3&autoplay=1
I was just trying to look up how and found there is a CLIP feature now added by Youtube right under the video that I had never noticed before!
I use this signature:
youtube.com/embed/[YOUR_VIDEO_ID]?start=[TIME_IN_SEC]&end=[TIME_IN_SEC]&autoplay=1
https://www.youtube.com/embed/2EWejmkKlxs?start=1230&end=1246&autoplay=1

Resources