FreeTube/src/renderer/store/modules/utils.js

957 lines
28 KiB
JavaScript
Raw Normal View History

import fs from 'fs/promises'
import path from 'path'
2022-02-02 04:11:38 +01:00
import i18n from '../../i18n/index'
2023-08-03 14:48:23 +02:00
import { set as vueSet } from 'vue'
Store Revamp / Full database synchronization across windows (#1833) * History: Refactor history module * Profiles: Refactor profiles module * IPC: Move channel ids to their own file and make them constants * IPC: Replace single sync channel for one channel per sync type * Everywhere: Replace default profile id magic strings with constant ref * Profiles: Refactor `activeProfile` property from store This commit makes it so that `activeProfile`'s getter returns the entire profile, while the related update function only needs the profile id (instead of the previously used array index) to change the currently active profile. This change was made due to inconsistency regarding the active profile when creating new profiles. If a new profile coincidentally landed in the current active profile's array index after sorting, the app would mistakenly change to it without any action from the user apart from the profile's creation. Turning the profile id into the selector instead solves this issue. * Revert "Store: Implement history synchronization between windows" This reverts commit 99b61e617873412eb393d8f4dfccd8f8c172021f. This is necessary for an upcoming improved implementation of the history synchronization. * History: Remove unused mutation * Everywhere: Create abstract database handlers The project now utilizes abstract handlers to fetch, modify or otherwise manipulate data from the database. This facilitates 3 aspects of the app, in addition of making them future proof: - Switching database libraries is now trivial Since most of the app utilizes the abstract handlers, it's incredibly easily to change to a different DB library. Hypothetically, all that would need to be done is to simply replace the the file containing the base handlers, while the rest of the app would go unchanged. - Syncing logic between Electron and web is now properly separated There are now two distinct DB handling APIs: the Electron one and the web one. The app doesn't need to manually choose the API, because it's detected which platform is being utilized on import. - All Electron windows now share the same database instance This provides a single source of truth, improving consistency regarding data manipulation and windows synchronization. As a sidenote, syncing implementation has been left as is (web unimplemented; Electron only syncs settings, remaining datastore syncing will be implemented in the upcoming commits). * Electron/History: Implement history synchronization * Profiles: Implement suplementary profile creation logic * ft-profile-edit: Small fix on profile name missing display * Electron/Profiles: Implement profile synchronization * Electron/Playlists: Implement playlist synchronization
2021-12-15 19:42:24 +01:00
import { IpcChannels } from '../../../constants'
import { pathExists } from '../../helpers/filesystem'
import {
CHANNEL_HANDLE_REGEX,
createWebURL,
getVideoParamsFromUrl,
openExternalLink,
replaceFilenameForbiddenChars,
searchFiltersMatch,
showExternalPlayerUnsupportedActionToast,
showSaveDialog,
showToast
} from '../../helpers/utils'
Store Revamp / Full database synchronization across windows (#1833) * History: Refactor history module * Profiles: Refactor profiles module * IPC: Move channel ids to their own file and make them constants * IPC: Replace single sync channel for one channel per sync type * Everywhere: Replace default profile id magic strings with constant ref * Profiles: Refactor `activeProfile` property from store This commit makes it so that `activeProfile`'s getter returns the entire profile, while the related update function only needs the profile id (instead of the previously used array index) to change the currently active profile. This change was made due to inconsistency regarding the active profile when creating new profiles. If a new profile coincidentally landed in the current active profile's array index after sorting, the app would mistakenly change to it without any action from the user apart from the profile's creation. Turning the profile id into the selector instead solves this issue. * Revert "Store: Implement history synchronization between windows" This reverts commit 99b61e617873412eb393d8f4dfccd8f8c172021f. This is necessary for an upcoming improved implementation of the history synchronization. * History: Remove unused mutation * Everywhere: Create abstract database handlers The project now utilizes abstract handlers to fetch, modify or otherwise manipulate data from the database. This facilitates 3 aspects of the app, in addition of making them future proof: - Switching database libraries is now trivial Since most of the app utilizes the abstract handlers, it's incredibly easily to change to a different DB library. Hypothetically, all that would need to be done is to simply replace the the file containing the base handlers, while the rest of the app would go unchanged. - Syncing logic between Electron and web is now properly separated There are now two distinct DB handling APIs: the Electron one and the web one. The app doesn't need to manually choose the API, because it's detected which platform is being utilized on import. - All Electron windows now share the same database instance This provides a single source of truth, improving consistency regarding data manipulation and windows synchronization. As a sidenote, syncing implementation has been left as is (web unimplemented; Electron only syncs settings, remaining datastore syncing will be implemented in the upcoming commits). * Electron/History: Implement history synchronization * Profiles: Implement suplementary profile creation logic * ft-profile-edit: Small fix on profile name missing display * Electron/Profiles: Implement profile synchronization * Electron/Playlists: Implement playlist synchronization
2021-12-15 19:42:24 +01:00
2020-02-16 19:30:00 +01:00
const state = {
isSideNavOpen: false,
outlinesHidden: true,
2020-02-16 19:30:00 +01:00
sessionSearchHistory: [],
2020-08-18 17:51:56 +02:00
popularCache: null,
trendingCache: {
default: null,
music: null,
gaming: null,
movies: null
},
cachedPlaylist: null,
deArrowCache: {},
showProgressBar: false,
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
showAddToPlaylistPrompt: false,
showCreatePlaylistPrompt: false,
progressBarPercentage: 0,
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
toBeAddedToPlaylistVideoList: [],
newPlaylistDefaultProperties: {},
newPlaylistVideoObject: [],
regionNames: [],
regionValues: [],
recentBlogPosts: [],
2020-02-16 19:30:00 +01:00
searchSettings: {
sortBy: 'relevance',
time: '',
type: 'all',
duration: ''
},
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
externalPlayerNames: [],
externalPlayerValues: [],
externalPlayerCmdArguments: {},
lastVideoRefreshTimestampByProfile: {},
lastShortRefreshTimestampByProfile: {},
lastLiveRefreshTimestampByProfile: {},
lastCommunityRefreshTimestampByProfile: {},
lastPopularRefreshTimestamp: '',
lastTrendingRefreshTimestamp: '',
2020-02-16 19:30:00 +01:00
}
const getters = {
getIsSideNavOpen () {
return state.isSideNavOpen
},
getOutlinesHidden() {
return state.outlinesHidden
},
getCurrentVolume () {
return state.currentVolume
},
2020-02-16 19:30:00 +01:00
getSessionSearchHistory () {
return state.sessionSearchHistory
},
2023-08-03 14:48:23 +02:00
getDeArrowCache: (state) => {
return state.deArrowCache
},
getPopularCache () {
return state.popularCache
},
2020-08-22 22:37:09 +02:00
getTrendingCache () {
return state.trendingCache
},
getCachedPlaylist() {
return state.cachedPlaylist
},
2020-02-16 19:30:00 +01:00
getSearchSettings () {
return state.searchSettings
2020-08-24 04:56:33 +02:00
},
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
getShowAddToPlaylistPrompt () {
return state.showAddToPlaylistPrompt
},
getShowCreatePlaylistPrompt () {
return state.showCreatePlaylistPrompt
},
getToBeAddedToPlaylistVideoList () {
return state.toBeAddedToPlaylistVideoList
},
getNewPlaylistDefaultProperties () {
return state.newPlaylistDefaultProperties
},
getNewPlaylistVideoObject () {
return state.newPlaylistVideoObject
},
getShowProgressBar () {
return state.showProgressBar
},
getProgressBarPercentage () {
return state.progressBarPercentage
},
getRegionNames () {
return state.regionNames
},
getRegionValues () {
return state.regionValues
},
getRecentBlogPosts () {
return state.recentBlogPosts
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
},
getExternalPlayerNames () {
return state.externalPlayerNames
},
getExternalPlayerValues () {
return state.externalPlayerValues
},
getExternalPlayerCmdArguments () {
return state.externalPlayerCmdArguments
},
getLastTrendingRefreshTimestamp() {
return state.lastTrendingRefreshTimestamp
},
getLastPopularRefreshTimestamp() {
return state.lastPopularRefreshTimestamp
},
getLastCommunityRefreshTimestampByProfile: (state) => (profileId) => {
return state.lastCommunityRefreshTimestampByProfile[profileId]
},
getLastShortRefreshTimestampByProfile: (state) => (profileId) => {
return state.lastShortRefreshTimestampByProfile[profileId]
},
getLastLiveRefreshTimestampByProfile: (state) => (profileId) => {
return state.lastLiveRefreshTimestampByProfile[profileId]
},
getLastVideoRefreshTimestampByProfile: (state) => (profileId) => {
return state.lastVideoRefreshTimestampByProfile[profileId]
2020-02-16 19:30:00 +01:00
}
}
const actions = {
showOutlines({ commit }) {
commit('setOutlinesHidden', false)
},
hideOutlines({ commit }) {
commit('setOutlinesHidden', true)
},
async downloadMedia({ rootState }, { url, title, extension, fallingBackPath }) {
if (!process.env.IS_ELECTRON) {
openExternalLink(url)
return
}
const fileName = `${replaceFilenameForbiddenChars(title)}.${extension}`
const errorMessage = i18n.t('Downloading failed', { videoTitle: title })
const askFolderPath = rootState.settings.downloadAskPath
2022-02-02 04:11:38 +01:00
let folderPath = rootState.settings.downloadFolderPath
if (askFolderPath) {
2022-02-02 04:11:38 +01:00
const options = {
defaultPath: fileName,
filters: [
{
name: extension.toUpperCase(),
2022-02-02 04:11:38 +01:00
extensions: [extension]
}
]
}
const response = await showSaveDialog(options)
2022-02-02 04:11:38 +01:00
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return
}
folderPath = response.filePath
} else {
if (!(await pathExists(folderPath))) {
try {
await fs.mkdir(folderPath, { recursive: true })
} catch (err) {
console.error(err)
2022-10-14 07:59:49 +02:00
showToast(err)
return
}
}
folderPath = path.join(folderPath, fileName)
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
}
2022-10-14 07:59:49 +02:00
showToast(i18n.t('Starting download', { videoTitle: title }))
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
2022-02-02 04:11:38 +01:00
const response = await fetch(url).catch((error) => {
console.error(error)
2022-10-14 07:59:49 +02:00
showToast(errorMessage)
2022-02-02 04:11:38 +01:00
})
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
2022-02-02 04:11:38 +01:00
const reader = response.body.getReader()
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
const chunks = []
2022-02-02 04:11:38 +01:00
const handleError = (err) => {
console.error(err)
2022-10-14 07:59:49 +02:00
showToast(errorMessage)
2022-02-02 04:11:38 +01:00
}
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
2022-02-02 04:11:38 +01:00
const processText = async ({ done, value }) => {
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
if (done) {
2022-02-02 04:11:38 +01:00
return
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
}
chunks.push(value)
2022-02-02 04:11:38 +01:00
// Can be used in the future to determine download percentage
// const contentLength = response.headers.get('Content-Length')
// const receivedLength = value.length
// const percentage = receivedLength / contentLength
2022-02-02 04:11:38 +01:00
await reader.read().then(processText).catch(handleError)
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
}
2022-02-02 04:11:38 +01:00
await reader.read().then(processText).catch(handleError)
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
const blobFile = new Blob(chunks)
const buffer = await blobFile.arrayBuffer()
try {
await fs.writeFile(folderPath, new DataView(buffer))
showToast(i18n.t('Downloading has completed', { videoTitle: title }))
} catch (err) {
console.error(err)
showToast(errorMessage)
}
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
},
parseScreenshotCustomFileName: function({ rootState }, payload) {
return new Promise((resolve, reject) => {
const { pattern = rootState.settings.screenshotFilenamePattern, date, playerTime, videoId } = payload
const keywords = [
['%Y', date.getFullYear()], // year 4 digits
['%M', (date.getMonth() + 1).toString().padStart(2, '0')], // month 2 digits
['%D', date.getDate().toString().padStart(2, '0')], // day 2 digits
['%H', date.getHours().toString().padStart(2, '0')], // hour 2 digits
['%N', date.getMinutes().toString().padStart(2, '0')], // minute 2 digits
['%S', date.getSeconds().toString().padStart(2, '0')], // second 2 digits
['%T', date.getMilliseconds().toString().padStart(3, '0')], // millisecond 3 digits
['%s', parseInt(playerTime)], // video position second n digits
['%t', (playerTime % 1).toString().slice(2, 5) || '000'], // video position millisecond 3 digits
['%i', videoId] // video id
]
let parsedString = pattern
for (const [key, value] of keywords) {
parsedString = parsedString.replaceAll(key, value)
}
if (parsedString !== replaceFilenameForbiddenChars(parsedString)) {
reject(new Error(i18n.t('Settings.Player Settings.Screenshot.Error.Forbidden Characters')))
}
let filename
if (parsedString.indexOf(path.sep) !== -1) {
const lastIndex = parsedString.lastIndexOf(path.sep)
filename = parsedString.substring(lastIndex + 1)
} else {
filename = parsedString
}
if (!filename) {
reject(new Error(i18n.t('Settings.Player Settings.Screenshot.Error.Empty File Name')))
}
resolve(parsedString)
})
},
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
showAddToPlaylistPromptForManyVideos ({ commit }, { videos: videoObjectArray, newPlaylistDefaultProperties }) {
let videoDataValid = true
if (!Array.isArray(videoObjectArray)) {
videoDataValid = false
}
let missingKeys = []
if (videoDataValid) {
const requiredVideoKeys = [
'videoId',
'title',
'author',
'authorId',
'lengthSeconds',
// `timeAdded` should be generated when videos are added
// Not when a prompt is displayed
// 'timeAdded',
// `playlistItemId` should be generated anyway
// 'playlistItemId',
// `type` should be added in action anyway
// 'type',
]
// Using `every` to loop and `return false` to break
videoObjectArray.every((video) => {
const videoPropertyKeys = Object.keys(video)
const missingKeysHere = requiredVideoKeys.filter(x => !videoPropertyKeys.includes(x))
if (missingKeysHere.length > 0) {
videoDataValid = false
missingKeys = missingKeysHere
return false
}
// Return true to continue loop
return true
})
}
if (!videoDataValid) {
// Print error and abort
const errorMsgText = 'Incorrect videos data passed when opening playlist prompt'
console.error(errorMsgText)
console.error({
videoObjectArray,
missingKeys,
})
throw new Error(errorMsgText)
}
commit('setShowAddToPlaylistPrompt', true)
commit('setToBeAddedToPlaylistVideoList', videoObjectArray)
if (newPlaylistDefaultProperties != null) {
commit('setNewPlaylistDefaultProperties', newPlaylistDefaultProperties)
}
},
hideAddToPlaylistPrompt ({ commit }) {
commit('setShowAddToPlaylistPrompt', false)
// The default value properties are only valid until prompt is closed
commit('resetNewPlaylistDefaultProperties')
},
showCreatePlaylistPrompt ({ commit }, data) {
commit('setShowCreatePlaylistPrompt', true)
commit('setNewPlaylistVideoObject', data)
},
hideCreatePlaylistPrompt ({ commit }) {
commit('setShowCreatePlaylistPrompt', false)
},
updateShowProgressBar ({ commit }, value) {
commit('setShowProgressBar', value)
},
async getRegionData ({ commit }, { locale }) {
const localePathExists = process.env.GEOLOCATION_NAMES.includes(locale)
// Exclude __dirname from path if not in electron
const fileLocation = `${process.env.IS_ELECTRON ? process.env.NODE_ENV === 'development' ? '.' : __dirname : ''}/static/geolocations/`
const pathName = `${fileLocation}${localePathExists ? locale : 'en-US'}.json`
const countries = process.env.IS_ELECTRON ? JSON.parse(await fs.readFile(pathName)) : await (await fetch(createWebURL(pathName))).json()
const regionNames = countries.map((entry) => { return entry.name })
const regionValues = countries.map((entry) => { return entry.code })
commit('setRegionNames', regionNames)
commit('setRegionValues', regionValues)
},
async getYoutubeUrlInfo({ rootState, state }, urlStr) {
// Returns
// - urlType [String] `video`, `playlist`
//
// If `urlType` is "video"
// - videoId [String]
// - timestamp [String]
//
// If `urlType` is "playlist"
// - playlistId [String]
// - query [Object]
//
// If `urlType` is "search"
// - searchQuery [String]
// - query [Object]
//
// If `urlType` is "hashtag"
// Nothing else
//
// If `urlType` is "channel"
// - channelId [String]
//
// If `urlType` is "unknown"
// Nothing else
//
// If `urlType` is "invalid_url"
// Nothing else
if (CHANNEL_HANDLE_REGEX.test(urlStr)) {
urlStr = `https://www.youtube.com/${urlStr}`
}
const { videoId, timestamp, playlistId } = getVideoParamsFromUrl(urlStr)
if (videoId) {
return {
urlType: 'video',
videoId,
playlistId,
timestamp
}
}
let url
try {
url = new URL(urlStr)
} catch {
return {
urlType: 'invalid_url'
}
}
let urlType = 'unknown'
const channelPattern =
/^\/(?:(?:channel|user|c)\/)?(?<channelId>[^/]+)(?:\/(?<tab>join|featured|videos|shorts|live|streams|podcasts|releases|playlists|about|community|channels))?\/?$/
const hashtagPattern = /^\/hashtag\/(?<tag>[^#&/?]+)$/
const typePatterns = new Map([
['playlist', /^(\/playlist\/?|\/embed(\/?videoseries)?)$/],
['search', /^\/results|search\/?$/],
['hashtag', hashtagPattern],
['channel', channelPattern]
])
for (const [type, pattern] of typePatterns) {
const matchFound = pattern.test(url.pathname)
if (matchFound) {
urlType = type
break
}
}
switch (urlType) {
case 'playlist': {
if (!url.searchParams.has('list')) {
throw new Error('Playlist: "list" field not found')
}
const playlistId = url.searchParams.get('list')
url.searchParams.delete('list')
const query = {}
for (const [param, value] of url.searchParams) {
query[param] = value
}
return {
urlType: 'playlist',
playlistId,
query
}
}
case 'search': {
let searchQuery = null
if (url.searchParams.has('search_query')) {
// https://www.youtube.com/results?search_query={QUERY}
searchQuery = url.searchParams.get('search_query')
url.searchParams.delete('search_query')
}
if (url.searchParams.has('q')) {
// https://redirect.invidious.io/search?q={QUERY}
searchQuery = url.searchParams.get('q')
url.searchParams.delete('q')
}
if (searchQuery == null) {
throw new Error('Search: "search_query" field not found')
}
const searchSettings = state.searchSettings
const query = {
sortBy: searchSettings.sortBy,
time: searchSettings.time,
type: searchSettings.type,
duration: searchSettings.duration
}
for (const [param, value] of url.searchParams) {
query[param] = value
}
return {
urlType: 'search',
searchQuery,
query
}
}
case 'hashtag': {
const match = url.pathname.match(hashtagPattern)
const hashtag = match.groups.tag
return {
urlType: 'hashtag',
hashtag
}
}
/*
Using RegExp named capture groups from ES2018
To avoid access to specific captured value broken
Channel URL (ID-based)
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw/about
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw/channels
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw/community
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw/featured
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw/join
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw/playlists
https://www.youtube.com/channel/UCfMJ2MchTSW2kWaT0kK94Yw/videos
Custom URL
https://www.youtube.com/c/YouTubeCreators
https://www.youtube.com/c/YouTubeCreators/about
etc.
Legacy Username URL
https://www.youtube.com/user/ufoludek
https://www.youtube.com/user/ufoludek/about
etc.
*/
case 'channel': {
const match = url.pathname.match(channelPattern)
const channelId = match.groups.channelId
if (!channelId) {
throw new Error('Channel: could not extract id')
}
let subPath = null
switch (match.groups.tab) {
case 'shorts':
subPath = 'shorts'
break
case 'live':
case 'streams':
subPath = 'live'
break
case 'playlists':
subPath = 'playlists'
break
case 'podcasts':
subPath = 'podcasts'
break
case 'releases':
subPath = 'releases'
break
case 'channels':
case 'about':
subPath = 'about'
break
case 'community':
Channel community page (#1568) * Comunity page strings, Communtiy tab, Community initial API call Added: 1) Community page strings - the first few strings are now available 2) Community tab - A clickable tab is now displayed on channel pages 3) Community initial API call - on loading the page, the initial access * Comunity page strings, Communtiy tab, Community initial API call Added: 1) Community page strings - the first few strings are now available 2) Community tab - A clickable tab is now displayed on channel pages 3) Community initial API call - on loading the page, the initial access * Data returning added * Comunity page strings, Communtiy tab, Community initial API call Added: 1) Community page strings - the first few strings are now available 2) Community tab - A clickable tab is now displayed on channel pages 3) Community initial API call - on loading the page, the initial access * Data returning added * Images are now displayed in the community tab * Comunity page strings, Communtiy tab, Community initial API call Added: 1) Community page strings - the first few strings are now available 2) Community tab - A clickable tab is now displayed on channel pages 3) Community initial API call - on loading the page, the initial access * Data returning added * Images are now displayed in the community tab * Added primitive video display * Current changes * Added preston's change with the ftcard and started on some layout basics * Created Community Post Component and added fetch more button + functionality * Fixed problem with videothumbnails not loading and adjusted their height to 100% in the ft-list sass file * Added poll and ft-list-video to the community page * Added author name placeholder (missing in module), the published date, the likes and dislikes as well as comment counts to posts. Additionally scaling of images was added * Added basis for community page playlists * Finalized a setup for playlists when wide enough * Fix for missing key in custom list * Added publish date translation * Add empty alt tags Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * fix accessibility issue Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * change: ununique ids to classes * add missing alt tag * Redirect channel/id/community to the channel's community tab * update yt-channel-info * update to 3.0.1 * Update yarn.lock * add basic multiImage support * use tiny-slider for multiImage community posts * update getChannelCommunityPostsMore * Update yarn.lock * fix yarn lock * swap community and about tab * Update yarn.lock * Fix missing comma * Removed trailing spaces * Clearing all community post data when changing to another channel * Restructuring of how the post cards are added, Empty page text, ft-element-list props customization 1) Now the community page uses the same setup of ft-element-list as the other pages on the channel. 2) If no posts are available, now it displays a message saying so 3) The ft-element-list component's display style can now be forced into a certain display mode (list/grid) with the new prop. It will overwrite the corresponding default value for list display * Fixed display text path * Fix lint" * Adjusted css to fit to new layout * Final touches community page to tidy up the console * fix icons, fix linter * fix hiding showmore button for community page * fix showToast calls * change all this.showToast to showToaast * reinstall tinyslider * use helpers * small fixes * fix: getting continuation of community posts * remove unused code * improve slider style import * fix hiding 'ShowMore' button * fix weird typo in css * add invidous community tab support * remove console testing code * Apply suggestions from code review Co-authored-by: absidue <48293849+absidue@users.noreply.github.com> * implement suggestions, improve thumbnail replacement * use flip horizontal * readd invidious fallback code, remove author name workaround * replace another google domain when using invidious * suppport invidious multiImage posts * Use youtube.js for community posts * add invidious polls, remove support for fetching more * reorder icons alpabetically * re-allow loading more when using localapi * fix styling of multiImage, hide NA text * fix loading playlist * fix spacing of items * fix issue with direct url to community tab * make review recommendations Co-Authored-By: absidue <48293849+absidue@users.noreply.github.com> * fix displaying selected tab, get best quality image --------- Co-authored-by: Preston <freetubeapp@protonmail.com> Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
2023-03-04 09:56:04 +01:00
subPath = 'community'
break
default:
subPath = 'videos'
break
}
return {
urlType: 'channel',
channelId,
subPath,
// The original URL could be from Invidious.
// We need to make sure it starts with youtube.com, so that YouTube's resolve endpoint can recognise it
url: `https://www.youtube.com${url.pathname}`
}
}
default: {
// Unknown URL type
return {
urlType: 'unknown'
}
}
}
},
clearSessionSearchHistory ({ commit }) {
commit('setSessionSearchHistory', [])
},
async getExternalPlayerCmdArgumentsData ({ commit }, payload) {
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
const fileName = 'external-player-map.json'
/* eslint-disable-next-line n/no-path-concat */
const fileLocation = process.env.NODE_ENV === 'development' ? './static/' : `${__dirname}/static/`
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
const fileData = await fs.readFile(`${fileLocation}${fileName}`)
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
const externalPlayerMap = JSON.parse(fileData).map((entry) => {
return { name: entry.name, value: entry.value, cmdArguments: entry.cmdArguments }
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
})
// Sort external players alphabetically & case-insensitive, keep default entry at the top
const playerNone = externalPlayerMap.shift()
externalPlayerMap.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }))
externalPlayerMap.unshift(playerNone)
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
const externalPlayerNames = externalPlayerMap.map((entry) => { return entry.name })
const externalPlayerValues = externalPlayerMap.map((entry) => { return entry.value })
const externalPlayerCmdArguments = externalPlayerMap.reduce((result, item) => {
result[item.value] = item.cmdArguments
return result
}, {})
commit('setExternalPlayerNames', externalPlayerNames)
commit('setExternalPlayerValues', externalPlayerValues)
commit('setExternalPlayerCmdArguments', externalPlayerCmdArguments)
},
openInExternalPlayer ({ state, rootState }, payload) {
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
const args = []
const externalPlayer = rootState.settings.externalPlayer
const cmdArgs = state.externalPlayerCmdArguments[externalPlayer]
const executable = rootState.settings.externalPlayerExecutable !== ''
? rootState.settings.externalPlayerExecutable
: cmdArgs.defaultExecutable
const ignoreWarnings = rootState.settings.externalPlayerIgnoreWarnings
const ignoreDefaultArgs = rootState.settings.externalPlayerIgnoreDefaultArgs
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
const customArgs = rootState.settings.externalPlayerCustomArgs
if (ignoreDefaultArgs) {
if (typeof customArgs === 'string' && customArgs !== '') {
const custom = customArgs.split(';')
args.push(...custom)
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
}
if (payload.videoId != null) args.push(`${cmdArgs.videoUrl}https://www.youtube.com/watch?v=${payload.videoId}`)
} else {
// Append custom user-defined arguments,
// or use the default ones specified for the external player.
if (typeof customArgs === 'string' && customArgs !== '') {
const custom = customArgs.split(';')
args.push(...custom)
} else if (typeof cmdArgs.defaultCustomArguments === 'string' && cmdArgs.defaultCustomArguments !== '') {
const defaultCustomArguments = cmdArgs.defaultCustomArguments.split(';')
args.push(...defaultCustomArguments)
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
}
if (payload.watchProgress > 0 && payload.watchProgress < payload.videoLength - 10) {
if (typeof cmdArgs.startOffset === 'string') {
if (cmdArgs.defaultExecutable.startsWith('mpc')) {
// For mpc-hc and mpc-be, which require startOffset to be in milliseconds
args.push(cmdArgs.startOffset, (Math.trunc(payload.watchProgress) * 1000))
} else if (cmdArgs.startOffset.endsWith('=')) {
// For players using `=` in arguments
// e.g. vlc --start-time=xxxxx
args.push(`${cmdArgs.startOffset}${payload.watchProgress}`)
} else {
// For players using space in arguments
// e.g. smplayer -start xxxxx
args.push(cmdArgs.startOffset, Math.trunc(payload.watchProgress))
}
} else if (!ignoreWarnings) {
showExternalPlayerUnsupportedActionToast(externalPlayer, i18n.t('Video.External Player.Unsupported Actions.starting video at offset'))
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
}
}
if (payload.playbackRate != null) {
if (typeof cmdArgs.playbackRate === 'string') {
args.push(`${cmdArgs.playbackRate}${payload.playbackRate}`)
} else if (!ignoreWarnings) {
showExternalPlayerUnsupportedActionToast(externalPlayer, i18n.t('Video.External Player.Unsupported Actions.setting a playback rate'))
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
}
}
// Check whether the video is in a playlist
if (typeof cmdArgs.playlistUrl === 'string' && payload.playlistId != null && payload.playlistId !== '') {
if (payload.playlistIndex != null) {
if (typeof cmdArgs.playlistIndex === 'string') {
args.push(`${cmdArgs.playlistIndex}${payload.playlistIndex}`)
} else if (!ignoreWarnings) {
showExternalPlayerUnsupportedActionToast(externalPlayer, i18n.t('Video.External Player.Unsupported Actions.opening specific video in a playlist (falling back to opening the video)'))
}
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
}
if (payload.playlistReverse) {
if (typeof cmdArgs.playlistReverse === 'string') {
args.push(cmdArgs.playlistReverse)
} else if (!ignoreWarnings) {
showExternalPlayerUnsupportedActionToast(externalPlayer, i18n.t('Video.External Player.Unsupported Actions.reversing playlists'))
}
}
if (payload.playlistShuffle) {
if (typeof cmdArgs.playlistShuffle === 'string') {
args.push(cmdArgs.playlistShuffle)
} else if (!ignoreWarnings) {
showExternalPlayerUnsupportedActionToast(externalPlayer, i18n.t('Video.External Player.Unsupported Actions.shuffling playlists'))
}
}
if (payload.playlistLoop) {
if (typeof cmdArgs.playlistLoop === 'string') {
args.push(cmdArgs.playlistLoop)
} else if (!ignoreWarnings) {
showExternalPlayerUnsupportedActionToast(externalPlayer, i18n.t('Video.External Player.Unsupported Actions.looping playlists'))
}
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
}
// If the player supports opening playlists but not indexes, send only the video URL if an index is specified
if (cmdArgs.playlistIndex == null && payload.playlistIndex != null && payload.playlistIndex !== '') {
args.push(`${cmdArgs.videoUrl}https://youtube.com/watch?v=${payload.videoId}`)
} else {
args.push(`${cmdArgs.playlistUrl}https://youtube.com/playlist?list=${payload.playlistId}`)
}
} else {
if (payload.playlistId != null && payload.playlistId !== '' && !ignoreWarnings) {
showExternalPlayerUnsupportedActionToast(externalPlayer, i18n.t('Video.External Player.Unsupported Actions.opening playlists'))
}
if (payload.videoId != null) {
args.push(`${cmdArgs.videoUrl}https://www.youtube.com/watch?v=${payload.videoId}`)
}
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
}
}
const videoOrPlaylist = payload.playlistId != null && payload.playlistId !== ''
? i18n.t('Video.External Player.playlist')
: i18n.t('Video.External Player.video')
2022-10-14 07:59:49 +02:00
showToast(i18n.t('Video.External Player.OpeningTemplate', { videoOrPlaylist, externalPlayer }))
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
if (process.env.IS_ELECTRON) {
const { ipcRenderer } = require('electron')
ipcRenderer.send(IpcChannels.OPEN_IN_EXTERNAL_PLAYER, { executable, args })
}
},
updateLastCommunityRefreshTimestampByProfile ({ commit }, payload) {
commit('updateLastCommunityRefreshTimestampByProfile', payload)
},
updateLastShortRefreshTimestampByProfile ({ commit }, payload) {
commit('updateLastShortRefreshTimestampByProfile', payload)
},
updateLastLiveRefreshTimestampByProfile ({ commit }, payload) {
commit('updateLastLiveRefreshTimestampByProfile', payload)
},
updateLastVideoRefreshTimestampByProfile ({ commit }, payload) {
commit('updateLastVideoRefreshTimestampByProfile', payload)
}
}
2020-02-16 19:30:00 +01:00
const mutations = {
toggleSideNav (state) {
state.isSideNavOpen = !state.isSideNavOpen
},
setOutlinesHidden(state, value) {
state.outlinesHidden = value
},
setShowProgressBar (state, value) {
state.showProgressBar = value
},
setProgressBarPercentage (state, value) {
state.progressBarPercentage = value
},
2020-02-16 19:30:00 +01:00
setSessionSearchHistory (state, history) {
state.sessionSearchHistory = history
},
setDeArrowCache (state, cache) {
state.deArrowCache = cache
},
addVideoToDeArrowCache (state, payload) {
const sameVideo = state.deArrowCache[payload.videoId]
if (!sameVideo) {
2023-08-03 14:48:23 +02:00
// setting properties directly doesn't trigger watchers in Vue 2,
// so we need to use Vue's set function
vueSet(state.deArrowCache, payload.videoId, payload)
}
},
addThumbnailToDeArrowCache (state, payload) {
vueSet(state.deArrowCache, payload.videoId, payload)
},
2020-02-16 19:30:00 +01:00
addToSessionSearchHistory (state, payload) {
const sameSearch = state.sessionSearchHistory.findIndex((search) => {
return search.query === payload.query && searchFiltersMatch(payload.searchSettings, search.searchSettings)
2020-02-16 19:30:00 +01:00
})
if (sameSearch !== -1) {
state.sessionSearchHistory[sameSearch].data = payload.data
if (payload.nextPageRef) {
// Local API
state.sessionSearchHistory[sameSearch].nextPageRef = payload.nextPageRef
} else if (payload.searchPage) {
// Invidious API
state.sessionSearchHistory[sameSearch].searchPage = payload.searchPage
}
2020-02-16 19:30:00 +01:00
} else {
state.sessionSearchHistory.push(payload)
}
},
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
setShowAddToPlaylistPrompt (state, payload) {
state.showAddToPlaylistPrompt = payload
},
setShowCreatePlaylistPrompt (state, payload) {
state.showCreatePlaylistPrompt = payload
},
setToBeAddedToPlaylistVideoList (state, payload) {
state.toBeAddedToPlaylistVideoList = payload
},
setNewPlaylistDefaultProperties (state, payload) {
state.newPlaylistDefaultProperties = payload
},
resetNewPlaylistDefaultProperties (state) {
state.newPlaylistDefaultProperties = {}
},
setNewPlaylistVideoObject (state, payload) {
state.newPlaylistVideoObject = payload
},
setPopularCache (state, value) {
state.popularCache = value
},
setTrendingCache (state, { value, page }) {
state.trendingCache[page] = value
2020-08-22 22:37:09 +02:00
},
setLastTrendingRefreshTimestamp (state, timestamp) {
state.lastTrendingRefreshTimestamp = timestamp
},
setLastPopularRefreshTimestamp (state, timestamp) {
state.lastPopularRefreshTimestamp = timestamp
},
updateLastCommunityRefreshTimestampByProfile (state, { profileId, timestamp }) {
vueSet(state.lastCommunityRefreshTimestampByProfile, profileId, timestamp)
},
updateLastShortRefreshTimestampByProfile (state, { profileId, timestamp }) {
vueSet(state.lastShortRefreshTimestampByProfile, profileId, timestamp)
},
updateLastLiveRefreshTimestampByProfile (state, { profileId, timestamp }) {
vueSet(state.lastLiveRefreshTimestampByProfile, profileId, timestamp)
},
updateLastVideoRefreshTimestampByProfile (state, { profileId, timestamp }) {
vueSet(state.lastVideoRefreshTimestampByProfile, profileId, timestamp)
},
2023-03-26 11:32:36 +02:00
clearTrendingCache(state) {
state.trendingCache = {
default: null,
music: null,
gaming: null,
movies: null
}
},
setCachedPlaylist(state, value) {
state.cachedPlaylist = value
},
2020-02-16 19:30:00 +01:00
setSearchSortBy (state, value) {
state.searchSettings.sortBy = value
},
setSearchTime (state, value) {
state.searchSettings.time = value
},
setSearchType (state, value) {
state.searchSettings.type = value
},
setSearchDuration (state, value) {
state.searchSettings.duration = value
},
setRegionNames (state, value) {
state.regionNames = value
},
setRegionValues (state, value) {
state.regionValues = value
},
setRecentBlogPosts (state, value) {
state.recentBlogPosts = value
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
},
setExternalPlayerNames (state, value) {
state.externalPlayerNames = value
},
setExternalPlayerValues (state, value) {
state.externalPlayerValues = value
},
setExternalPlayerCmdArguments (state, value) {
state.externalPlayerCmdArguments = value
2020-02-16 19:30:00 +01:00
}
}
export default {
state,
getters,
actions,
mutations
}