From ae819fc4423d7702fc4e759e26966e0f312143da Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Fri, 1 Mar 2019 17:13:14 +0100 Subject: [PATCH 1/5] fix: Hide the scrollbar when selecting a sub --- app/components/SubSelector/SubSelector.js | 2 ++ app/screens/Player/PlayerScreen.js | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/SubSelector/SubSelector.js b/app/components/SubSelector/SubSelector.js index d8f3c0a..bb712e4 100644 --- a/app/components/SubSelector/SubSelector.js +++ b/app/components/SubSelector/SubSelector.js @@ -123,6 +123,8 @@ export default class SubSelector extends React.Component { initialNumToRender={12} windowSize={32} renderItem={this.renderSub} + showsHorizontalScrollIndicator={false} + showsVerticalScrollIndicator={false} keyExtractor={(item, index) => `${item.language}-${index}`} ListHeaderComponent={() => } ListFooterComponent={() => ( diff --git a/app/screens/Player/PlayerScreen.js b/app/screens/Player/PlayerScreen.js index f1ca4d1..6c0964e 100644 --- a/app/screens/Player/PlayerScreen.js +++ b/app/screens/Player/PlayerScreen.js @@ -5,14 +5,11 @@ import RNFS from 'react-native-fs' import GoogleCast, { CastButton } from 'react-native-google-cast' import StaticServer from 'react-native-static-server' import TorrentStreamer from 'react-native-torrent-streamer' -import { Constants, utils } from 'popcorn-sdk' +import { utils } from 'popcorn-sdk' import Orientation from 'react-native-orientation' -import { TextTrackType } from 'react-native-video' import i18n from 'modules/i18n' -import PopcornSDK from 'modules/PopcornSDK' import SubtitlesManager from 'modules/SubtitlesManager' -import sortAB from 'modules/utils/sortAB' import Typography from 'components/Typography' import Button from 'components/Button' @@ -194,9 +191,10 @@ export default class VideoPlayer extends React.Component { buffer : '100', doneBuffering: true, loading : false, + casting : castState.toLowerCase() === 'connected', } - if (castState.toLowerCase() === 'connected') { + if (newState.casting) { await this.startCasting(data.url) } else { From 040b8901a01d9fb5e2dc7760388de42502258e12 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Mon, 4 Mar 2019 18:59:38 +0100 Subject: [PATCH 2/5] feat: You can search for better qualities for episodes from item screen --- .../QualitySelector/QualitySelector.js | 23 +++++++---- .../QualitySelectorContainer.js | 7 ++++ .../QualitySelector/QualtiySelectorActions.js | 41 +++++++++++++++++++ app/components/QualitySelector/index.js | 2 +- app/screens/Item/ItemConstants.js | 3 ++ .../SeasonsAndEpisodes/Episode/Episode.js | 6 +-- app/screens/Item/ItemReducer.js | 36 ++++++++++++++++ app/screens/Item/ItemScreen.js | 4 +- app/screens/MyEpisodes/MyEpisodesScreen.js | 11 +++-- 9 files changed, 118 insertions(+), 15 deletions(-) create mode 100644 app/components/QualitySelector/QualitySelectorContainer.js create mode 100644 app/components/QualitySelector/QualtiySelectorActions.js diff --git a/app/components/QualitySelector/QualitySelector.js b/app/components/QualitySelector/QualitySelector.js index 9999b30..3e4f6a3 100644 --- a/app/components/QualitySelector/QualitySelector.js +++ b/app/components/QualitySelector/QualitySelector.js @@ -4,6 +4,7 @@ import * as Animatable from 'react-native-animatable' import { material } from 'react-native-typography' import i18n from 'modules/i18n' +import PopcornSDK from 'modules/PopcornSDK' import BaseButton from 'components/BaseButton' import Button from 'components/Button' @@ -94,7 +95,15 @@ export default class QualitySelector extends React.Component { } handleSearchForBetter = () => { + const { fetchedBetterOnes, item, episodeToPlay } = this.props + fetchedBetterOnes( + item.show + ? item.show + : item, + + episodeToPlay, + ) } render() { @@ -125,13 +134,13 @@ export default class QualitySelector extends React.Component { /> - {/**/} - {/**/} - {/*{i18n.t('search for better')}*/} - {/**/} - {/**/} + + + {qualities.map((quality) => ( (dispatch) => { + Popcorn.searchEpisode( + item, + episode, + ).then((results) => { + if (item.type === Constants.TYPE_MOVIE) { + dispatch({ + type : ItemConstants.FETCHED_BETTER_FOR_MOVIE, + payload: { + newTorrents: results, + }, + }) + + } else if (item.type === Constants.TYPE_SHOW) { + dispatch({ + type : ItemConstants.FETCHED_BETTER_FOR_EPISODE, + payload: { + season : episode.season, + episode : episode.number, + newTorrents: results, + }, + }) + } else if (item.type === Constants.TYPE_SHOW_EPISODE) { // From My Episodes + // TODO:: This one still needs to be done + + // dispatch({ + // type : ItemConstants.FETCHED_BETTER_FOR_EPISODE, + // payload: { + // season : episode.season, + // episode : episode.number, + // newTorrents: results, + // }, + // }) + } + }) +} diff --git a/app/components/QualitySelector/index.js b/app/components/QualitySelector/index.js index 3baef9b..74b8a77 100644 --- a/app/components/QualitySelector/index.js +++ b/app/components/QualitySelector/index.js @@ -1 +1 @@ -export { default } from './QualitySelector' +export { default } from './QualitySelectorContainer' diff --git a/app/screens/Item/ItemConstants.js b/app/screens/Item/ItemConstants.js index 2106b42..9783982 100644 --- a/app/screens/Item/ItemConstants.js +++ b/app/screens/Item/ItemConstants.js @@ -18,3 +18,6 @@ export const REMOVE_FROM_BOOKMARKS = `${REDUCER_NAME}.remove.from.bookmarks` export const MARK_MOVIE_WATCHED = `${REDUCER_NAME}.mark.watched.movie` export const MARK_MOVIE_UNWATCHED = `${REDUCER_NAME}.mark.unwatched.movie` + +export const FETCHED_BETTER_FOR_EPISODE = `${REDUCER_NAME}.fetched.better.for.episode` +export const FETCHED_BETTER_FOR_MOVIE = `${REDUCER_NAME}.fetched.better.for.movie` diff --git a/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js b/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js index fb40652..3a51163 100644 --- a/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js +++ b/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js @@ -70,10 +70,10 @@ export default class Episode extends React.Component { } handlePlayItem = () => { - const { playItem, hasTorrents, torrents, ...episode } = this.props + const { playItem, ...episode } = this.props - if (hasTorrents) { - playItem(torrents, episode) + if (episode.hasTorrents) { + playItem(episode.torrents, this.props) } } diff --git a/app/screens/Item/ItemReducer.js b/app/screens/Item/ItemReducer.js index 1f6060e..1289b86 100644 --- a/app/screens/Item/ItemReducer.js +++ b/app/screens/Item/ItemReducer.js @@ -63,6 +63,42 @@ export default (state = ItemConstants.INITIAL_STATE, action) => { }, } + case ItemConstants.FETCHED_BETTER_FOR_MOVIE: + return { + ...state, + item: { + ...state.item, + torrents: action.payload.newTorrents, + }, + } + + case ItemConstants.FETCHED_BETTER_FOR_EPISODE: + return { + ...state, + item: { + ...state.item, + seasons: state.item.seasons.map((season) => { + if (season.number !== action.payload.season) { + return season + } + + return { + ...season, + episodes: season.episodes.map((episode) => { + if (episode.number !== action.payload.episode) { + return episode + } + + return { + ...episode, + torrents: action.payload.newTorrents, + } + }), + } + }), + }, + } + default: return state diff --git a/app/screens/Item/ItemScreen.js b/app/screens/Item/ItemScreen.js index 6fce89b..db7bbdf 100644 --- a/app/screens/Item/ItemScreen.js +++ b/app/screens/Item/ItemScreen.js @@ -156,7 +156,7 @@ export default class Item extends React.PureComponent { render() { const { item, isLoading } = this.props - const { selectFromTorrents } = this.state + const { selectFromTorrents, episodeToPlay } = this.state return ( @@ -234,6 +234,8 @@ export default class Item extends React.PureComponent { diff --git a/app/screens/MyEpisodes/MyEpisodesScreen.js b/app/screens/MyEpisodes/MyEpisodesScreen.js index ccab352..4ff7ef3 100644 --- a/app/screens/MyEpisodes/MyEpisodesScreen.js +++ b/app/screens/MyEpisodes/MyEpisodesScreen.js @@ -36,8 +36,8 @@ const styles = StyleSheet.create({ }, noItemsContainer: { - width : '100%', - height : height, + width : '100%', + height: height, justifyContent: 'center', alignItems : 'center', @@ -187,7 +187,7 @@ export class MyEpisodes extends React.PureComponent { render() { const { modes: { myEpisodes: { items, refreshing, fetching } } } = this.props - const { selectFromTorrents } = this.state + const { selectFromTorrents, episodeToPlay } = this.state return ( @@ -224,6 +224,11 @@ export class MyEpisodes extends React.PureComponent { /> From 1773ba8e891168583de7ca23f8ee33e58c9bafdd Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Mar 2019 22:06:54 +0100 Subject: [PATCH 3/5] feat: Movies can also now search for better qualities --- .../QualitySelector/QualitySelector.js | 35 +++++++++++++++---- .../QualitySelectorContainer.js | 7 +++- .../QualitySelector/QualtiySelectorActions.js | 29 +++++++-------- app/screens/Home/HomeConstants.js | 2 ++ app/screens/Home/HomeReducer.js | 22 ++++++++++++ app/screens/Item/ItemConstants.js | 11 +++--- app/screens/Item/ItemContainer.js | 2 -- app/screens/Item/ItemReducer.js | 19 ++++++++-- app/screens/Item/ItemSelectors.js | 8 ++--- app/screens/MyEpisodes/MyEpisodesScreen.js | 1 + 10 files changed, 100 insertions(+), 36 deletions(-) diff --git a/app/components/QualitySelector/QualitySelector.js b/app/components/QualitySelector/QualitySelector.js index 3e4f6a3..fde56de 100644 --- a/app/components/QualitySelector/QualitySelector.js +++ b/app/components/QualitySelector/QualitySelector.js @@ -1,10 +1,9 @@ import React from 'react' -import { StyleSheet, View, Text } from 'react-native' +import { StyleSheet, View, Text, ActivityIndicator } from 'react-native' import * as Animatable from 'react-native-animatable' import { material } from 'react-native-typography' import i18n from 'modules/i18n' -import PopcornSDK from 'modules/PopcornSDK' import BaseButton from 'components/BaseButton' import Button from 'components/Button' @@ -55,6 +54,11 @@ const styles = StyleSheet.create({ position: 'absolute', bottom : 20, }, + + fetchingBetter: { + position: 'absolute', + top : 100, + }, }) export default class QualitySelector extends React.Component { @@ -69,15 +73,21 @@ export default class QualitySelector extends React.Component { return {} } + static defaultProps = { + myEpisodesScreen:false, + } + state = { hidden : false, qualities: null, } playQuality = (quality) => { - const { playItem, torrents } = this.props + const { playItem, torrents, fetchingBetter } = this.props - playItem(torrents[quality]) + if (!fetchingBetter) { + playItem(torrents[quality]) + } } handleAnimationEnd = () => { @@ -95,7 +105,7 @@ export default class QualitySelector extends React.Component { } handleSearchForBetter = () => { - const { fetchedBetterOnes, item, episodeToPlay } = this.props + const { fetchedBetterOnes, item, episodeToPlay, myEpisodesScreen } = this.props fetchedBetterOnes( item.show @@ -103,11 +113,12 @@ export default class QualitySelector extends React.Component { : item, episodeToPlay, + myEpisodesScreen ) } render() { - const { torrents, cancel } = this.props + const { torrents, cancel, fetchingBetter } = this.props const { hidden, qualities } = this.state if (hidden && !torrents) { @@ -134,6 +145,18 @@ export default class QualitySelector extends React.Component { /> + {fetchingBetter && ( + + + + )} + + {qualities.length === 0 && ( + + {i18n.t('No qualities available! Try to search')} + + )} + {qualities.map((quality) => ( - this.playQuality(quality)}> - - {quality} - - + animation={'fadeIn'} + duration={200} + useNativeDriver> + this.playQuality(quality)}> + + {quality} + + + ))} )} diff --git a/app/modules/i18n/translations/en.json b/app/modules/i18n/translations/en.json index ae72c55..c5679a8 100644 --- a/app/modules/i18n/translations/en.json +++ b/app/modules/i18n/translations/en.json @@ -30,5 +30,7 @@ "Episodes aired within the last 7 days from shows you follow will appear here": "Episodes aired within the last 7 days from shows you follow will appear here", "Subtitles": "Subtitles", "None": "None", - "search for better": "search for better" + "search for better": "search for better", + "search for qualities": "search for qualities", + "No qualities available! Try to search": "No qualities available! Try to search" } diff --git a/app/modules/i18n/translations/nl.json b/app/modules/i18n/translations/nl.json index afe2d06..3020c7c 100644 --- a/app/modules/i18n/translations/nl.json +++ b/app/modules/i18n/translations/nl.json @@ -30,5 +30,7 @@ "Episodes aired within the last 7 days from shows you follow will appear here": "Afleveringen die de afgelopen 7 dagen uitgekomen zijn van series die je volgt komen hier", "Subtitles": "Ondertiteling", "None": "Geen", - "search for better": "zoek naar betere" + "search for better": "zoek naar betere", + "search for qualities": "zoeken", + "No qualities available! Try to search": "Niks beschikbaar! Probeer zoeken" } diff --git a/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js b/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js index 3a51163..ae9994b 100644 --- a/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js +++ b/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js @@ -72,9 +72,7 @@ export default class Episode extends React.Component { handlePlayItem = () => { const { playItem, ...episode } = this.props - if (episode.hasTorrents) { - playItem(episode.torrents, this.props) - } + playItem(episode.torrents, this.props) } getAirsDate = () => { @@ -87,7 +85,7 @@ export default class Episode extends React.Component { } render() { - const { hasTorrents, title, summary, number, images, hasAired } = this.props + const { title, summary, number, images, hasAired } = this.props const { showPlaceholder } = this.props return ( @@ -113,8 +111,8 @@ export default class Episode extends React.Component { iconStyle={{ margin: 0 }} backgroundColor={'transparent'} borderRadius={0} - name={hasTorrents ? 'play-circle-outline' : 'cancel'} - color={hasTorrents ? '#FFF' : 'red'} + name={'play-circle-outline'} + color={'#FFF'} size={60} /> )} diff --git a/app/screens/Item/ItemScreen.js b/app/screens/Item/ItemScreen.js index db7bbdf..98b4a05 100644 --- a/app/screens/Item/ItemScreen.js +++ b/app/screens/Item/ItemScreen.js @@ -49,6 +49,23 @@ export default class Item extends React.PureComponent { episodeToPlay : null, } + static getDerivedStateFromProps(props, state) { + const { episodeToPlay, selectFromTorrents } = state + + if (episodeToPlay && selectFromTorrents) { + const { item } = props + + const season = item.seasons.find(season => season.number === episodeToPlay.season) + const newEpisode = season.episodes.find(episode => episode.number === episodeToPlay.number) + + return { + selectFromTorrents: newEpisode ? newEpisode.torrents : selectFromTorrents, + } + } + + return {} + } + componentDidMount() { Orientation.lockToPortrait() @@ -136,7 +153,7 @@ export default class Item extends React.PureComponent { navigate('Player', { torrent, - item: playItem + item: playItem, }) } diff --git a/app/screens/MyEpisodes/MyEpisodesScreen.js b/app/screens/MyEpisodes/MyEpisodesScreen.js index 25a428d..d4b599b 100644 --- a/app/screens/MyEpisodes/MyEpisodesScreen.js +++ b/app/screens/MyEpisodes/MyEpisodesScreen.js @@ -77,7 +77,7 @@ export class MyEpisodes extends React.PureComponent { const { myEpisodes: { items } } = props const newEpisode = items.find(item => item.id === episodeToPlay.id) - + return { selectFromTorrents: newEpisode ? newEpisode.torrents : selectFromTorrents, }