Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
PrestonN committed Jun 28, 2020
2 parents 8a58087 + 49f742b commit 07f0206
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 110 deletions.
218 changes: 125 additions & 93 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FreeTube",
"productName": "FreeTube",
"version": "0.7.2",
"version": "0.7.3",
"description": "An Open Source YouTube app for privacy.",
"main": "src/js/init.js",
"scripts": {
Expand Down Expand Up @@ -94,12 +94,12 @@
"commonjs": "0.0.1",
"dateformat": "^3.0.3",
"electron-context-menu": "^0.15.0",
"jquery": "^3.4.1",
"jquery": "^3.5.0",
"jsdom": "^15.2.0",
"mustache": "^3.1.0",
"nedb": "^1.8.0",
"opml-to-json": "0.0.3",
"vue": "^2.6.10",
"ytdl-core": "^1.0.3"
"ytdl-core": "^3.1.1"
}
}
4 changes: 2 additions & 2 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,11 @@ function playVideo(videoId, playlistId = '') {
// Search through the returned object to get the 360p and 720p video URLs (If available)
videoUrls.forEach((video) => {
switch (video.itag) {
case 18:
case '18':
playerView.video360p = decodeURIComponent(video.url);
// ft.log(playerView.video360p);
break;
case 22:
case '22':
playerView.video720p = decodeURIComponent(video.url);
// ft.log(playerView.video720p);
break;
Expand Down
23 changes: 18 additions & 5 deletions src/js/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ let playerView = new Vue({
playlistShowList: true,
recommendedVideoList: [],
playlistVideoList: [],
distractionFreeMode: false
distractionFreeMode: false,
includeCurrentTime: false
},
methods: {
channel: (channelId) => {
Expand Down Expand Up @@ -947,13 +948,16 @@ let playerView = new Vue({
playerView.legacySeen = false;
playerView.playerSeen = true;
},
toggleSave: (videoId) => {
addSavedVideo(videoId);
},
copyYouTube: (videoId) => {
const url = 'https://youtube.com/watch?v=' + videoId;
const url = 'https://youtube.com/watch?v=' + videoId + currentTimeParameter();
clipboard.writeText(url);
showToast('URL has been copied to the clipboard');
},
openYouTube: (videoId) => {
shell.openExternal('https://youtube.com/watch?v=' + videoId);
shell.openExternal('https://youtube.com/watch?v=' + videoId + currentTimeParameter());
},
openYouTubeNoCookie: (videoId) => {
const url = 'https://www.youtube-nocookie.com/embed/' + videoId;
Expand All @@ -965,12 +969,12 @@ let playerView = new Vue({
showToast('URL has been copied to the clipboard');
},
copyInvidious: (videoId) => {
const url = invidiousInstance + '/watch?v=' + videoId;
const url = invidiousInstance + '/watch?v=' + videoId + currentTimeParameter();
clipboard.writeText(url);
showToast('URL has been copied to the clipboard');
},
openInvidious: (videoId) => {
shell.openExternal(invidiousInstance + '/watch?v=' + videoId);
shell.openExternal(invidiousInstance + '/watch?v=' + videoId + currentTimeParameter());
},
save: (videoId) => {
toggleSavedVideo(videoId);
Expand Down Expand Up @@ -1786,3 +1790,12 @@ function hideViews() {
editProfileView.seen = false;
backButtonView.lastView = false;
}

function currentTimeParameter(){
if (!playerView.includeCurrentTime) return "";
if (typeof (playerView.currentTime) !== 'undefined') return "&t=" + Math.floor(playerView.currentTime);
if (typeof (player) !== 'undefined') return "&t=" + Math.floor(player.currentTime);
const legacyPlayer = $('#legacyPlayer').get(0);
if (typeof (legacyPlayer) !== 'undefined') return "&t=" + Math.floor(legacyPlayer.currentTime);
return "";
}
5 changes: 3 additions & 2 deletions src/js/videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ function displayVideo(videoData, listType = '') {
let published = new Date(videoData.published * 1000);
let hours = 0;

if (now < published.getTime()) {
video.publishedDate = 'Premieres on ' + published.toLocaleString();
if (videoData.isUpcoming) {
const premiereDate = new Date(videoData.premiereTimestamp * 1000);
video.publishedDate = 'Premieres on ' + premiereDate.toLocaleString();
} else {
if (time >= 3600) {
hours = Math.floor(time / 3600);
Expand Down
13 changes: 13 additions & 0 deletions src/style/player.css
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,19 @@ iframe {
width: 100%;
}

.recommendThumbnail i {
color: white;
background-color: black;
padding: 6px;
opacity: 0.7;
position: relative;
}

.recommendVideoSave {
bottom: 145px;
left: 222px;
}

.recommendTitle {
font-size: 16px;
font-weight: bold;
Expand Down
13 changes: 8 additions & 5 deletions src/templates/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
<div class='smallButton shareButton'>
<span>SHARE</span> <i class="fas fa-angle-down"></i>
<div class='shareTypes'>
<input type="checkbox" id="timeCheckbox" v-model="includeCurrentTime">
<label for="timeCheckbox">AT CURRENT TIME</label>
<ul>
<li v-on:click='copyYouTube(videoId)'>COPY YOUTUBE LINK</li>
<li v-on:click='openYouTube(videoId)'>OPEN IN YOUTUBE</li>
Expand Down Expand Up @@ -123,14 +125,15 @@
<div v-if='!distractionFreeMode' id='recommendations'>
<strong>Recommendations</strong>
<div v-for='video in recommendedVideoList'>
<div class='recommendVideo' v-on:click='play(video.id)'>
<div class='recommendVideo'>
<div class='recommendThumbnail'>
<img :src='video.thumbnail'></img>
<img v-on:click='play(video.id)' :src='video.thumbnail'></img>
<p v-on:click='play(video.id)' class='videoDuration'>{{video.duration}}</p>
<i class="fas fa-history recommendVideoSave" v-on:click='toggleSave(video.id)'></i>
</div>
<p class='recommendTitle'>{{video.title}}</p>
<p class='recommendChannel'>{{video.channelName}}</p>
<p class='recommendDate'>{{video.viewCount}}</p>
<p v-on:click='play(video.id)' class='recommendTitle'>{{video.title}}</p>
<p v-on:click='play(video.id)' class='recommendChannel'>{{video.channelName}}</p>
<p v-on:click='play(video.id)' class='recommendDate'>{{video.viewCount}}</p>
</div>
<hr />
</div>
Expand Down

0 comments on commit 07f0206

Please sign in to comment.