mirror of https://github.com/FreeTubeApp/FreeTube
Make History Functionality more Responsive
This commit is contained in:
parent
5aba0d6cda
commit
5d2706848d
|
@ -13,7 +13,7 @@
|
|||
<link rel="stylesheet" href="style/select.css">
|
||||
<link rel="stylesheet" href="style/fa-solid.min.css">
|
||||
<link rel="stylesheet" href="style/fontawesome-all.min.css">
|
||||
<title>Freetube Player</title>
|
||||
<title>FreeTube Player</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
@ -73,7 +73,6 @@ let playPauseVideo = function (event) {
|
|||
* Handle keyboard shortcut commands.
|
||||
*/
|
||||
let videoShortcutHandler = function (event) {
|
||||
|
||||
if (event.which == 68 && event.altKey === true) {
|
||||
$('#search').focus();
|
||||
}
|
||||
|
|
|
@ -25,22 +25,27 @@ along with FreeTube. If not, see <http://www.gnu.org/licenses/>.
|
|||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function addToHistory(videoId){
|
||||
const data = {
|
||||
videoId: videoId,
|
||||
timeWatched: new Date().getTime(),
|
||||
};
|
||||
|
||||
historyDb.findOne({ videoId: videoId }, function (err, doc) {
|
||||
function addToHistory(data){
|
||||
historyDb.findOne({ videoId: data.videoId }, function (err, doc) {
|
||||
if(doc === null) {
|
||||
historyDb.insert(data, (err, newDoc) => {});
|
||||
} else {
|
||||
historyDb.update(
|
||||
{ videoId: videoId },
|
||||
{
|
||||
$set: {
|
||||
timeWatched: data.timeWatched,
|
||||
}
|
||||
{ videoId: data.videoId },
|
||||
{
|
||||
videoId: data.videoId,
|
||||
author: data.author,
|
||||
authorId: data.authorId,
|
||||
published: data.published,
|
||||
publishedText: data.publishedText,
|
||||
description: data.description,
|
||||
viewCount: data.viewCount,
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
lengthSeconds: data.lengthSeconds,
|
||||
videoThumbnails: data.videoThumbnails,
|
||||
type: 'video',
|
||||
timeWatched: data.timeWatched,
|
||||
}, {}, (err, newDoc) => {});
|
||||
}
|
||||
});
|
||||
|
@ -76,10 +81,36 @@ function showHistory(){
|
|||
timeWatched: -1
|
||||
}).exec((err, docs) => {
|
||||
docs.forEach((video, index) => {
|
||||
invidiousAPI('videos', video.videoId, {}, (data) => {
|
||||
data.position = index;
|
||||
displayVideo(data, 'history');
|
||||
});
|
||||
if (video.authorId === undefined) {
|
||||
// History data is from old version of FreeTube, update data for future calls.
|
||||
invidiousAPI('videos', video.videoId, {}, (data) => {
|
||||
let publishedText = new Date(data.published * 1000);
|
||||
publishedText = dateFormat(publishedText, "mmm dS, yyyy");
|
||||
let videoData = {
|
||||
videoId: video.videoId,
|
||||
published: data.published,
|
||||
publishedText: publishedText,
|
||||
description: data.description,
|
||||
viewCount: data.viewCount,
|
||||
title: data.title,
|
||||
lengthSeconds: data.lengthSeconds,
|
||||
videoThumbnails: data.videoThumbnails[4].url,
|
||||
author: data.author,
|
||||
authorId: data.authorId,
|
||||
liveNow: false,
|
||||
paid: false,
|
||||
type: 'video',
|
||||
timeWatched: video.timeWatched,
|
||||
};
|
||||
addToHistory(videoData);
|
||||
videoData.position = index;
|
||||
displayVideo(videoData, 'history');
|
||||
});
|
||||
}
|
||||
else{
|
||||
video.position = index;
|
||||
displayVideo(video, 'history');
|
||||
}
|
||||
});
|
||||
|
||||
loadingView.seen = false;
|
||||
|
|
|
@ -106,7 +106,7 @@ function playVideo(videoId, playlistId = '') {
|
|||
//playerView.videoUrl = playerView.liveManifest;
|
||||
}
|
||||
|
||||
if (!useEmbedPlayer && data.player_response.captions.playerCaptionsTracklistRenderer.captionTracks !== undefined) {
|
||||
if (!useEmbedPlayer && typeof(data.player_response.captions) !== 'undefined') {
|
||||
data.player_response.captions.playerCaptionsTracklistRenderer.captionTracks.forEach((caption) => {
|
||||
let subtitleUrl = invidiousInstance + '/api/v1/captions/' + videoId + '?label=' + caption.name.simpleText;
|
||||
|
||||
|
@ -240,7 +240,25 @@ function playVideo(videoId, playlistId = '') {
|
|||
}
|
||||
|
||||
if (rememberHistory === true){
|
||||
addToHistory(videoId);
|
||||
let historyData = {
|
||||
videoId: videoId,
|
||||
published: data.published,
|
||||
publishedText: playerView.publishedDate,
|
||||
description: data.description,
|
||||
viewCount: data.viewCount,
|
||||
title: playerView.videoTitle,
|
||||
lengthSeconds: data.lengthSeconds,
|
||||
videoThumbnails: playerView.videoThumbnail,
|
||||
author: playerView.channelName,
|
||||
authorId: playerView.channelId,
|
||||
liveNow: false,
|
||||
paid: false,
|
||||
type: 'video',
|
||||
timeWatched: new Date().getTime(),
|
||||
};
|
||||
|
||||
console.log(historyData);
|
||||
addToHistory(historyData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -184,7 +184,12 @@ function displayVideo(videoData, listType = '') {
|
|||
|
||||
video.youtubeUrl = 'https://youtube.com/watch?v=' + video.id;
|
||||
video.invidiousUrl = 'https://invidio.us/watch?v=' + video.id;
|
||||
video.thumbnail = videoData.videoThumbnails[4].url;
|
||||
if (typeof(videoData.videoThumbnails) === 'string'){
|
||||
video.thumbnail = videoData.videoThumbnails;
|
||||
}
|
||||
else {
|
||||
video.thumbnail = videoData.videoThumbnails[4].url;
|
||||
}
|
||||
video.title = videoData.title;
|
||||
video.channelName = videoData.author;
|
||||
video.channelId = videoData.authorId;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<input type="checkbox" id="torSwitch" name="set-name" class="switch-input" :checked='useTor'>
|
||||
<label for="torSwitch" class="switch-label">Use Tor / Proxy for API calls</label>
|
||||
<div class="input-text-settings">
|
||||
<label for="proxyAddress">Proxy Address (Example: SOCKS5://127.0.0.1:9050):</label>
|
||||
<label for="proxyAddress">Proxy Address (Example: SOCKS5://127.0.0.1:9050 ): </label>
|
||||
<input type="text" id="proxyAddress" name="set-name" v-model="proxyAddress">
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue