mark external video as watched

This commit is contained in:
unclekingpin 2023-07-05 13:27:53 -07:00
parent df00d762fe
commit b01e8ff2bc
3 changed files with 27 additions and 8 deletions

View file

@ -150,6 +150,7 @@ const MetaDetails = ({ urlParams, queryParams }) => {
<StreamsList <StreamsList
className={styles['streams-list']} className={styles['streams-list']}
streams={metaDetails.streams} streams={metaDetails.streams}
video={video}
/> />
: :
metaPath !== null ? metaPath !== null ?

View file

@ -9,7 +9,7 @@ const { useServices } = require('stremio/services');
const StreamPlaceholder = require('./StreamPlaceholder'); const StreamPlaceholder = require('./StreamPlaceholder');
const styles = require('./styles'); const styles = require('./styles');
const Stream = ({ className, addonName, name, description, thumbnail, progress, deepLinks, ...props }) => { const Stream = ({ className, videoId, addonName, name, description, thumbnail, progress, deepLinks, ...props }) => {
const profile = useProfile(); const profile = useProfile();
const streamingServer = useStreamingServer(); const streamingServer = useStreamingServer();
const { core } = useServices(); const { core } = useServices();
@ -29,10 +29,22 @@ const Stream = ({ className, addonName, name, description, thumbnail, progress,
: :
null; null;
}, [deepLinks, profile, streamingServer]); }, [deepLinks, profile, streamingServer]);
const onClick = React.useCallback((e) => { const markVideoAsWatched = React.useCallback(() => {
if (typeof videoId === 'string') {
core.transport.dispatch({
action: 'MetaDetails',
args: {
action: 'MarkVideoAsWatched',
args: [videoId, true]
}
});
}
}, [videoId]);
const onClick = React.useCallback((event) => {
if (href === null) { if (href === null) {
// link does not lead to the player, it is expected to // link does not lead to the player, it is expected to
// open with local video player through the streaming server // open with local video player through the streaming server
markVideoAsWatched();
core.transport.dispatch({ core.transport.dispatch({
action: 'StreamingServer', action: 'StreamingServer',
args: { args: {
@ -43,15 +55,18 @@ const Stream = ({ className, addonName, name, description, thumbnail, progress,
} }
} }
}); });
} else if (profile.settings.playerType === 'external') { } else if (profile.settings.playerType !== 'internal') {
markVideoAsWatched();
toast.show({ toast.show({
type: 'success', type: 'success',
title: 'Stream opened in external player', title: 'Stream opened in external player',
timeout: 4000 timeout: 4000
}); });
} }
props.onClick(e); if (typeof props.onClick === 'function') {
}, [href, deepLinks, props.onClick, profile, toast]); props.onClick(event);
}
}, [href, deepLinks, props.onClick, profile, toast, markVideoAsWatched]);
const forceDownload = React.useMemo(() => { const forceDownload = React.useMemo(() => {
// we only do this in one case to force the download // we only do this in one case to force the download
// of a M3U playlist generated in the browser // of a M3U playlist generated in the browser
@ -95,6 +110,7 @@ Stream.Placeholder = StreamPlaceholder;
Stream.propTypes = { Stream.propTypes = {
className: PropTypes.string, className: PropTypes.string,
videoId: PropTypes.string,
addonName: PropTypes.string, addonName: PropTypes.string,
name: PropTypes.string, name: PropTypes.string,
description: PropTypes.string, description: PropTypes.string,

View file

@ -12,7 +12,7 @@ const styles = require('./styles');
const ALL_ADDONS_KEY = 'ALL'; const ALL_ADDONS_KEY = 'ALL';
const StreamsList = ({ className, ...props }) => { const StreamsList = ({ className, video, ...props }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { core } = useServices(); const { core } = useServices();
const [selectedAddon, setSelectedAddon] = React.useState(ALL_ADDONS_KEY); const [selectedAddon, setSelectedAddon] = React.useState(ALL_ADDONS_KEY);
@ -105,6 +105,7 @@ const StreamsList = ({ className, ...props }) => {
{filteredStreams.map((stream, index) => ( {filteredStreams.map((stream, index) => (
<Stream <Stream
key={index} key={index}
videoId={video?.id}
addonName={stream.addonName} addonName={stream.addonName}
name={stream.name} name={stream.name}
description={stream.description} description={stream.description}
@ -119,7 +120,7 @@ const StreamsList = ({ className, ...props }) => {
} }
<Button className={styles['install-button-container']} title={t('ADDON_CATALOGUE_MORE')} href={'#/addons'}> <Button className={styles['install-button-container']} title={t('ADDON_CATALOGUE_MORE')} href={'#/addons'}>
<Icon className={styles['icon']} icon={'ic_addons'} /> <Icon className={styles['icon']} icon={'ic_addons'} />
<div className={styles['label']}>{ t('ADDON_CATALOGUE_MORE') }</div> <div className={styles['label']}>{t('ADDON_CATALOGUE_MORE')}</div>
</Button> </Button>
</div> </div>
); );
@ -127,7 +128,8 @@ const StreamsList = ({ className, ...props }) => {
StreamsList.propTypes = { StreamsList.propTypes = {
className: PropTypes.string, className: PropTypes.string,
streams: PropTypes.arrayOf(PropTypes.object).isRequired streams: PropTypes.arrayOf(PropTypes.object).isRequired,
video: PropTypes.object
}; };
module.exports = StreamsList; module.exports = StreamsList;