This commit is contained in:
Alexander Popov 2017-10-29 00:45:46 +03:00
commit 96ad2a323a
7 changed files with 163 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
y.js

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Alexander Popov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
README.md Normal file
View File

@ -0,0 +1,5 @@
YTCget
------
**Thanks:**
+ @takien: for [youtubeID.js](https://gist.github.com/takien/4077195) script.

34
index.html Normal file
View File

@ -0,0 +1,34 @@
<!doctype html>
<html>
<!--
/_ ... _ /_
/_//_/ ////_//_//_//\
_/ _//
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>YTCget</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="icon" href="//youtube.com/yts/img/favicon_32-vflOogEID.png" sizes="32x32">
<link rel="icon" href="//youtube.com/yts/img/favicon_48-vflVjB_Qk.png" sizes="48x48">
<link rel="icon" href="//youtube.com/yts/img/favicon_96-vflW9Ec0w.png" sizes="96x96">
<link rel="icon" href="//youtube.com/yts/img/favicon_144-vfliLAfaB.png" sizes="144x144">
<script type="text/javascript" src="youtubeID.js"></script>
<script type="text/javascript" src="ytcg.js"></script>
</head>
<body>
<div class="header">
<div class="wrap">
<form action="JavaScript:getCover()">
<input type="text" id="videoUrl" placeholder="YouTube video url"><!--
--><button type="submit">Search</button>
</form>
</div>
</div>
<div class="content">
<div class="wrap" id="ytImage">
</div>
</div>
<script type="text/javascript" src="/y.js"></script>
</body>
</html>

60
styles.css Normal file
View File

@ -0,0 +1,60 @@
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic');
* {
padding: 0; margin: 0; outline: 0;
font-family: "Roboto";
font-size: 1.1rem;
}
body {
background-color: #121212;
}
div.wrap {
max-width: 800px;
margin: 0 auto;
}
div.header {
background-color: #232323;
padding: 16px;
}
div.content {
margin-top: 10px;
}
div.content img {
border: 1px solid #808080;
max-width: 100%;
}
input, button {
box-sizing: border-box;
border: 1px solid #121212;
background-color: #232323;
font-size: 1rem;
padding: 8px;
}
input {
width: calc(100% - 100px);
color: #808080;
}
input::placeholder {
color: #818181;
}
input:focus {
background-color: #606060;
color: #ffffff;
}
button {
background-color: #343434;
color: #606060;
border-left: 0;
width: 100px;
}
button:hover {
color: #808080;
}

35
youtubeID.js Normal file
View File

@ -0,0 +1,35 @@
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
if(url[2] !== undefined) {
ID = url[2].split(/[^0-9a-z_\-]/i);
ID = ID[0];
}
else {
ID = url;
}
return ID;
}
/*
* Tested URLs:
var url = 'http://youtube.googleapis.com/v/4e_kz79tjb8?version=3';
url = 'https://www.youtube.com/watch?feature=g-vrec&v=Y1xs_xPb46M';
url = 'http://www.youtube.com/watch?feature=player_embedded&v=Ab25nviakcw#';
url = 'http://youtu.be/Ab25nviakcw';
url = 'http://www.youtube.com/watch?v=Ab25nviakcw';
url = '<iframe width="420" height="315" src="http://www.youtube.com/embed/Ab25nviakcw" frameborder="0" allowfullscreen></iframe>';
url = '<object width="420" height="315"><param name="movie" value="http://www.youtube-nocookie.com/v/Ab25nviakcw?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/Ab25nviakcw?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
url = 'http://i1.ytimg.com/vi/Ab25nviakcw/default.jpg';
url = 'https://www.youtube.com/watch?v=BGL22PTIOAM&feature=g-all-xit';
url = 'BGL22PTIOAM';
*/

7
ytcg.js Normal file
View File

@ -0,0 +1,7 @@
function getCover()
{
var videoUrl = document.getElementById('videoUrl').value;
var coverUrl = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg';
document.getElementById('ytImage').innerHTML =
'<a download href="' + coverUrl + '"><img src="'+ coverUrl +'"></a>';
}