Leverage browser caching for youtube thumbnails - youtube-api

I am using Youtube (v3)API for my website where many youtube video thumbnails are displayed.
For example something like: https://i1.ytimg.com/vi/0ZL_q7oUVrQ/mqdefault.jpg
When I check the Google Insights(https://developers.google.com/speed/pagespeed/insights/) for my website it complains about bad 'Leverage browser caching'. I had already taken care by adding expiry date for static resources coming from my server like js/css files but Google insights is mainly complaining about thumbnail images which are coming externally, direct from Youtube servers.
My website has many of these thumbnails and caching them is very important for fast page loads but youtube servers have set the expiry time for only 6 hours and I do not find a way to change that since they are external to my servers.
I would be very thankful if someone can suggest me of any better way to take care of browser caching for my usecase where resources are coming from external servers(like in my case thumbnails from youtube servers)
I am surprised that Youtube sets the expiry for only 6 hours though images are the least possible resources to change often...!

It's outside of your control so I don't think you can do anything about it.
These are your options:
Cache/update cache yourself.
Get the remote admin to change it (not possible with youtube).
Ignore.

Related

Get report of all assets from YouTube Content ID API

I represent a YouTube content owner and I use the YouTube Reporting API to get daily analytical reports on how well our many thousands of assets perform on YouTube.
Those reports only give an asset ID to reference the actual real world asset ie musical sound recording. I plan to read those reports, in bulk, into a streaming platform to get analytics of how the assets are performing. The issue I have is that, in order to match the analytics to the actual sound recording, I need a list of all the assets for which we have control.
I see the YouTube Content ID API gives access to asset lists through their assets and assetSearch resources. The thing is neither really work as the assets resource requires knowledge of the asset IDs already and assetSearch returns a paginated list of only 25 at a time.
What would be best for me would be a CSV of all the assets that I could pass into the streaming platform in one go rather than having to hit a search endpoint thousands of times to get an up-to-date list.
I don't really want to have to build a secondary service to have a database of those assets. It would make far more sense to get an up-to-date list all in one go every day. Is that something that any of the APIs offer?
All other streaming platforms offer some data with their analytics to help us identify what sound recording this relates to, but YouTube seem to make it difficult.
What kind of KPI's do you want to track of those assets? Views or revenue?
In case if its revenue, you could use the Reporting API to get the system-managed reports of the assets and parse and calculate the revenue accordingly.

Uploading a video to youtube from my swift app

I've been asked to integrate videos into an existing app which previously only let users upload posts with images.
I don't want to host the videos on my own server for the following reasons:
Server Bandwidth
File Size Limits and Storage Space
Slow-Loading Video or Unexpected Pauses During Playback
Issues with converting to specific formats
Piracy
Based off this article:
https://www.wp101.com/10-reasons-why-you-should-never-host-your-own-videos/
So I tried to research into where I could host the files and then I would simply have to store the URL in my db and use a video player to stream the content.
Vimeo and youtube seemed to be the main options I could find.
I'm wondering how best to implement, would I make use of a youtube API and on successful upload, grab the link and upload to my own server? I'm concerned this may be a long process for the end user.
Another problem is I can't see any swift examples (ZERO obj-c experience) of making the http request but perhaps it is still possible but I'd just have to write the code myself? I'm wondering if anyone has implemented anything like this already as I can't find any examples.
Looking at this question:
How do I upload a video to YouTube from within an iOS application?
None of the links in the comments work and the answer directs to the youtube 2.0 API and I'm concerned that this is now deprecated.
Any advice appreciated!

how to protect videos from being download in rails

I'm building a Rails app that has videos that users will see on the app and they will pay for it. So I need to ensure that no one can download the video. How can I protect, for example, that someone go to the source code the page and find the link and download it?
You can't really do this in standard Rails techniques. If you are serving the file yourself: Dirty Web Video Secret: If You Can See It, You Can Steal It
You can’t guarantee that a video can’t be copied, but you can make it harder by limiting the people with access to the video, by letting those people know that you can track how they view your videos, and by putting some reasonable technological hurdles in the way.
If you are OK using flash, then you can look at Brightcove's solution that uses "DRM" http://support.brightcove.com/en/video-cloud/docs/protecting-your-videos-drm
What do most people do?
They use an authenticated URL that expires (to prevent emailing and sharing), and trust their users won't download and share the videos. They then ignore those that do share (or file DCMA takedown requests).

Google Drive as a video hosting/streaming platform?

I'm developing an iOS app that generate video files and have a social gallery for users to display their clips. After a lot of research I found that Google Drive would be perfect to fit my needs so I did some testing and sucessfully made the app upload the file to GDrive and everything.
Now I need to stream the uploaded file in a MPMoviePlayerViewController, for that I would need some kind of direct link, I'm right? After my initial tests I used the variable WebContentLink as a source URL and it worked flawlessly, I was really happy with the result, however now it doesn't work anymore, I don't know what happened and I think the method that I used is not realiable? I tried all the other possible links and none of them seems to work.
Can someone give a guidance about if this is really supported by Google Drive and how it's the best way to archive that in a reliable way?
Thank you very much !
I too encounter the same error when I try to download 28 times (testing) the same 24mb file.
However I realise if I am to download using the content owner ID, it does allow downloading after the 28th time
https://docs.google.com/a/onwardsct.com/uc?id=0ByvXJAlpPqQPYWNqY0V3MGs0Ujg&export=download
Sorry, you can't view or download this file at this time.
Too many users have viewed or downloaded this file recently. Please try accessing the file again later. If the file you are trying to access is particularly large or is shared with many people, it may take up to 24 hours to be able to view or download the file. If you still can't access a file after 24 hours, contact your domain administrator.
The experience for streaming files natively is not ideal right now, sorry. It is something Google are working on.
You are doing this correctly though. The webContentLink should use the user's quota, and that should be enough for most cases. If you can give some specific numbers, we can look at it.
The embed link is the best way to show it on a mobile device, but as you say won't work everywhere.
yes, google drive can be used for hosting and stream videos as you like. It can also be used as demo server for web projects. Here is how to host a website on Google drive.

Patterns between YouTube m. and normal site urls

My site is not able to show uploaded youtube videos when the url is a mobile (m.) site, but it works for the normal youtube site. It seems to me that the mobile and normal urls differ in a pattern, as shown below:
http://www.youtube.com/watch?v=5ILbPFSc4_4
http://m.youtube.com/#/watch?v=5ILbPFSc4_4&desktop_uri=%2Fwatch%3Fv%3D5ILbPFSc4_4
obviously, the m. is added, as is the /#, and all the &desktop_uri... stuff.
and again:
http://www.youtube.com/watch?v=8To-6VIJZRE
http://m.youtube.com/#/watch?v=9To-6VIJZRE&desktop_uri=%2Fwatch%3Fv%3D8To-6VIJZRE
What we hope to do is check to see if the url is mobile site, and if it is, parse it so it shows as the normal site.
Does any one know if all youtube urls work this way--if this similar pattern works for all the same videos on mobile and normal sites?
In general, any time you attempt to parse URLs for sites (as opposed to web APIs) by hand, you're leaving yourself open to breakage. There's no "contract" in place that states that a common format will always be used for watch page URLs on the mobile site, or on the desktop site.
The oEmbed service is what you should use whenever you want to take a YouTube watch page URL as input and get information about the underlying video resource as output in a programmatic fashion. That being said, the oEmbed response doesn't include a canonical link to the desktop YouTube watch page, so it's not going to give you exactly what you want in this case. For many use cases, such as when you want to get the embed code for a video given its watch page URL, it's the right choice.
If you do code something by hand, please ensure that your code is deployed somewhere where it would be easy to update if the format of the watch pages ever do change.

Resources