Fix Importing of OPML files

This commit is contained in:
PrestonN 2019-03-01 10:43:07 -05:00
parent 8c42fb8cae
commit 80de67a747
3 changed files with 35 additions and 12 deletions

View File

@ -106,14 +106,17 @@ function playVideo(videoId, playlistId = '') {
//playerView.videoUrl = playerView.liveManifest;
}
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;
if (!useEmbedPlayer &&
typeof(data.player_response.captions) !== 'undefined' &&
typeof(data.player_response.captions.playerCaptionsTracklistRenderer) !== 'undefined' &&
typeof(data.player_response.captions.playerCaptionsTracklistRenderer.captionTracks) !== 'undefined') {
data.player_response.captions.playerCaptionsTracklistRenderer.captionTracks.forEach((caption) => {
let subtitleUrl = invidiousInstance + '/api/v1/captions/' + videoId + '?label=' + caption.name.simpleText;
videoHtml = videoHtml + '<track kind="subtitles" src="' + subtitleUrl + '" srclang="' + caption.languageCode + '" label="' + caption.name.simpleText + '">';
});
videoHtml = videoHtml + '<track kind="subtitles" src="' + subtitleUrl + '" srclang="' + caption.languageCode + '" label="' + caption.name.simpleText + '">';
});
playerView.subtitleHtml = videoHtml;
playerView.subtitleHtml = videoHtml;
}
loadingView.seen = false;

View File

@ -420,14 +420,34 @@ function importOpmlSubs(json){
return;
}
json.forEach((channel) => {
showToast('Importing susbcriptions, please wait.');
progressView.seen = true;
progressView.width = 0;
let counter = 0;
json.forEach((channel, index) => {
let channelId = channel['xmlurl'].replace('https://www.youtube.com/feeds/videos.xml?channel_id=', '');
addSubscription(channelId, false);
invidiousAPI('channels', channelId, {}, (data) => {
let subscription = {
channelId: data.authorId,
channelName: data.author,
channelThumbnail: data.authorThumbnails[2].url
};
addSubscription(subscription, false);
counter++;
progressView.progressWidth = (counter / json.length) * 100;
if ((counter + 1) == json.length) {
showToast('Subscriptions have been imported!');
progressView.seen = false;
progressView.seen = 0;
return;
}
});
});
window.setTimeout(displaySubs, 1000);
showToast('Subscriptions have been imported!');
return;
}
/**

View File

@ -40,8 +40,8 @@ function addSubscription(data, useToast = true) {
subDb.insert(data, (err, newDoc) => {
if (useToast) {
showToast('Added ' + data.channelName + ' to subscriptions.');
displaySubs();
}
displaySubs();
});
}