diff --git a/src/index.html b/src/index.html
index 2d7cd4743..65aab2155 100644
--- a/src/index.html
+++ b/src/index.html
@@ -13,7 +13,7 @@
-
Freetube Player
+ FreeTube Player
diff --git a/src/js/events.js b/src/js/events.js
index 66b1d6b81..4d5e3ce35 100644
--- a/src/js/events.js
+++ b/src/js/events.js
@@ -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();
}
diff --git a/src/js/history.js b/src/js/history.js
index da32cd4c8..4df612414 100644
--- a/src/js/history.js
+++ b/src/js/history.js
@@ -25,22 +25,27 @@ along with FreeTube. If not, see .
*
* @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;
diff --git a/src/js/player.js b/src/js/player.js
index 58fcf46dc..fb35ddc67 100644
--- a/src/js/player.js
+++ b/src/js/player.js
@@ -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);
}
});
}
diff --git a/src/js/videos.js b/src/js/videos.js
index 1fb11837a..5d99703b6 100644
--- a/src/js/videos.js
+++ b/src/js/videos.js
@@ -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;
diff --git a/src/templates/settings.html b/src/templates/settings.html
index 8bf461271..a75d48b4d 100644
--- a/src/templates/settings.html
+++ b/src/templates/settings.html
@@ -51,7 +51,7 @@
-
+