When a video is duplicated (let's say v = GgVH5fXXYSE) , is there a way i can find the videoid of the "good" one (the one that should work) with the duplicated id.
(so with GgVH5fXXYSE i could find eNqZgEgOfsw)
Thanks!
Unfortunately, there's no way to get this information. It's come up as a feature request a number of times in the past, and there are technical reasons why this can't be exposed in the YouTube Data API response.
If you have APP, that solely uploads file to particular (authorized) youtube account(s), then you can get it done using following method. Maintain a hash of all input files and while uploading file, check ,if you have old file having same hash as current file upload, and that old file was uploaded successfully, then don't upload that file and use youtube link = old file's ( having same hash as current file) youtube link.
Related
In the past, with Google Drive API v2, I could easily get thumbnails for pictures or videos with the property thumbnailLink on GTLDriveFile.
But now, with the API v3 which I currently use with Swift, the thumbnailLink of the files I get from Google Drive is nil, so what can I do to get thumbnails of images and videos stored in the user's Google Drive. I need to display theses in my iOS app.
Make sure to specify thumbnailLink in fields, such as
let query = GTLQueryDrive.queryForFilesList()
query.fields = "files(id, name, thumbnailLink)"
then you can access the property thumbnailLink for images and videos
You'd have to use the Drive REST API method Files: get. The result of that method contains thumbnailLink but according to the documentation it is 'a short-lived link to the file's thumbnail. Typically lasts on the order of hours.
Alternatively, you can cache the thumbnail in your application, reducing the count of drive api requests and thus improve your page performance. You need to fetch the information for the uploaded file. The easiest way of caching is to simply download the thumbnail and save it like fileid_thumb somewhere and upon the next request, you check if such a file exists before actually requesting the thumbnail. Check here the detailed explanation.
You can also upload a thumbnail by setting the contentHints.thumbnail property on the File resource during an insert or update call as follows:
Set contentHints.thumbnail.image to the URL-safe Base64-encoded image (see RFC 4648 section 5)
Set contentHints.thumbnail.mimeType to the appropriate type for the image format
You can also check the accepted answer in this SO question.
Hope this helps!
I am developing ios app in appcelerator studios .In that app i need to show thumbnails of remote service videos . I am getting videos data through JSON object. I am getting thumbnails for only one video rest of them also i am getting but those are append to first video of the JSON object.
can any one help me how to show thumbnails for remote located videos ?
Thanks in advance.
I'm not sure if I fully get your question, but from your title I take that you want to generate thumbnails for remove videos?
For this you can use the following API:
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.VideoPlayer-method-requestThumbnailImagesAtTimes
This does mean that you have to load in every single video (the view itself does not need to be visible to the user) which is quite heavy. So if at all possible it is better to get them from wherever you get the videos from, or use some middleware to generate and cache them there.
I've explored most of this topic using the previous question How do I get a list of uploaded videos for a certain channel with the new YouTube Data API (V3)?, but I wanted some specifics that build upon the answer given.
Is it possible to use the channel's username without calling a search query to get the channel ID? I have an https request that can get a search list shown below, but I'd rather not waste API quotas when I know the exact channel username.
https://www.googleapis.com/youtube/v3/search?q={channel_username}&key={my_api_key}&part=snippet
My hack for this is just take a videoid from the channel and extract a uploader ID from there, but its not elegant and won't work if the upload is removed.
Also, once I've worked my way down to getting the uploads key, how can I get a json that shows all of the uploads and not just a list of 25? If I do have to recursively call pages of uploads, how can I do that?
Thanks.
I think that to get a channel, using the channel's username, the only option is to use the search, and the best strategy to minimize the use of quota is to use a cache, or save the channel ID.
For a full list of videos uploaded, as JSON, you can use contentDetails.relatedPlaylists.uploads (the ID of the playlist that contains the channel's uploaded videos) and retrieve the PlaylistItems, using pages with 50 items per page, and using the nextPageToken value to retrieve each page in the result set.
I've found the answer. The correct way to go about it is to query the site using the search, but directly state the type of list to respond with, in effect searching only channels. This is done by
https://www.googleapis.com/youtube/v3/search?q={search_term}&key={API_key}&type=channel&part=snippet
As you can see the type is channel. By searching with a search term of the exact channel username, you'll get a return list with the first item object as the channel, and you can store the channel ID and upload ID from there.
To update this answer, you need to recognise the "quota limits".
As such, to use the "search?q=[search]" will incur a 100 quota usage.
Better to use "channels?part=id&forUsername={username]" as is only a quota of 1.
Then you can use "channels?part=id,snippet ....... &id={channel_ID]" to grab all your data
I'm developing a form where I want to allow users to either upload a file, or enter a url to an existing file.
The idea is to allow users to attach various 'multimedia' files to entries, some of which may be files from their hard drives (think images, word documents, etc) and some may be urls (youtube videos, images on flickr, etc)
Any ideas on how I can accomplish this? I'm currently using carrierwave to handle file uploads, and it seems to work well, but I want to store url's as well.
What I will probably do is to have a drop down in the file upload form to select if the file is from the disk or from external url.
By default it will set to "from disk", and if they select external url, you could use some AJAX magic and hide the file upload text box and have a text box to use the external url/script etc..
in the table, you can keep another two columns,
1 - external url
2 - file category (external / uploaded file)
by that way you can distinguish the files and how they what to display in the view
HTH
Don't save the url unless you really have too. The thing is that when you save a url, you can't process it to create a thumbnail or multiple styles of the image. Also, when you display the images in a page you will have to make external calls and that can slow down the page or even worse, if the link breaks sometime in the future your users will see an empty image.
Which is also the case with youtube videos. However, with videos you typically want to store and display more information than just the video. You can have two tables - one for videos and one for images. In the video table you have title, desc, author, duration, embed code, thumbnail (image attachment).
You can download any image when a URL is given and save it like a normal file.
Using carrierwave -
#object.remote_image_url = "http://www.foo.com/file.png"
#object.save
In the view, you would have both options, perhaps side by side and you can let them post to different actions. So if a file is selected and posted you save it normally. If a url is entered, then you can check if it's a video site or not - if video, parse out the info using the video_info gem and store it. Otherwise just use the two lines above and save the url image.
Note
My answer doesn't discuss the quality / nature of user inputs. The likely-hood of someone entering an incorrect url is high in my opinion, so you want to wrap attempts to save the url as an image in a begin-rescue block and perhaps using JS limit the video domains to just a few websites which you will be able to parse.
I have a script that downloads mp4 files from youtube. What it does is to generate link of the form http://youtube.com/get_video?video_id=*VIDEO_ID*&&t=*THE_TOKEN*=&fmt=18&asv=2, but it doesn't work anymore (noticed it today). What do you think?
Instead of trying to use get_video to get the video, try parsing fmt_url_map (format-url map) instead.
You should be able to find the fmt_url_map in the same place you found the token (like in the flashvars of the YouTube flash video player or inside the YouTube page somewhere). If you can't find it, send a request to http://www.youtube.com/get_video_info?video_id=VIDEO_ID and you should get a really long result that is in the format of name=value&name=value&... Find "fmt_url_map" inside this result (search through the result for a string that starts with "&fmt_url_map=" and ends with "&").
After you get this value (you may have to url-decode it), it will be something like (without the line breaks):
22|http://blah.youtube.com/videoplayback?blah,
35|http://blah.youtube.com/videoplayback?blah,
...
where each comma-separated entry starts with the fmt value (22 or 35 in the example), followed by a pipe character, which is then followed by the URL where you can use to download the video in that format. (This URL is client-specific, so a URL for a certain client most likely won't work with another client due to YouTube checking IPs. Also, the URLs do expire after a while.)
For a list of the different fmt values, see: http://en.wikipedia.org/wiki/YouTube#Quality_and_formats and show the "Comarison of YouTube media encoding options". NOTE: not all formats may be available for all videos.
Deprecated: won't work anymore!
If you want to download to a server you can use youtube-dl which still works.
Well it seems like they have removed the fmt option. See http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs.
I've created a node.js server that can stream YouTube videos directly to the client and it works. See https://github.com/licson0729/node-YouTubeStreamer for details.