From b7028054d599708fc7b67e4c379c46c035480ed3 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Mon, 10 Jul 2017 07:40:00 +0200 Subject: [PATCH] Small start on shows --- app/api/Butter.js | 15 +- app/api/Player/Player.js | 9 +- app/api/Player/PlayerStatuses.js | 1 + app/api/metadata/MetadataAdapter.js | 3 +- .../PctMetadataProvider/PctMetadataHelpers.js | 31 +- .../PctMetadataProvider.js | 8 +- .../metadata/TheMovieDBMetadataProvider.js | 265 ------------------ ...ovider.js => TraktMetadataProvider.js_old} | 0 .../TraktMetadataProvider.js | 206 ++++++++++++++ .../metadata/TraktMetadataProvider/index.js | 3 + app/api/metadata/example.js | 92 ------ .../PlyrPlayerProvider/PlyrPlayerProvider.js | 5 +- app/api/torrents/BaseTorrentProvider.js | 5 +- app/components/Item/Background/Background.js | 2 +- app/components/Item/Info/Info.js | 2 +- app/components/Item/Info/Info.scss | 1 + app/components/Item/ItemActions.js | 18 +- app/components/Item/ItemComponent.js | 6 +- app/components/Player/PlayerComponent.js | 4 + 19 files changed, 286 insertions(+), 390 deletions(-) delete mode 100644 app/api/metadata/TheMovieDBMetadataProvider.js rename app/api/metadata/{TraktMetadataProvider.js => TraktMetadataProvider.js_old} (100%) create mode 100644 app/api/metadata/TraktMetadataProvider/TraktMetadataProvider.js create mode 100644 app/api/metadata/TraktMetadataProvider/index.js delete mode 100644 app/api/metadata/example.js diff --git a/app/api/Butter.js b/app/api/Butter.js index 1fe127c6..e4f33c99 100644 --- a/app/api/Butter.js +++ b/app/api/Butter.js @@ -5,16 +5,19 @@ import TorrentAdapter from './torrents/TorrentAdapter' import MetadataAdapter from './metadata/MetadataAdapter' import PctMetadataProvider from './metadata/PctMetadataProvider' +import TraktMetadataProvider from './metadata/TraktMetadataProvider' export class Butter { metadata: MetadataAdapter + trakt: TraktMetadataProvider pctAdapter: PctMetadataProvider constructor() { this.metadata = MetadataAdapter this.pctAdapter = new PctMetadataProvider() + this.trakt = new TraktMetadataProvider() } getMovies = (page: number = 1, limit: number = 50) => this.pctAdapter.getMovies(page, limit) @@ -23,7 +26,17 @@ export class Butter { getShows = (page: number = 1, limit: number = 50) => this.pctAdapter.getShows(page, limit) - getShow = (itemId: string) => this.pctAdapter.getShow(itemId) + getShow = (itemId: string) => { + return this.pctAdapter.getShow(itemId).then(pctShow => { + + // Deze wordt leidend! Episode info van pctShow hier in mergen + this.trakt.getSeasons(pctShow.id).then(show => { + console.log('trakt', show) + }) + + return pctShow + }) + } searchTorrent = (itemId: string, type: string) => { return TorrentAdapter(itemId, type, {}, false) diff --git a/app/api/Player/Player.js b/app/api/Player/Player.js index acff7cea..313a727d 100644 --- a/app/api/Player/Player.js +++ b/app/api/Player/Player.js @@ -20,6 +20,8 @@ export class Player implements PlayerProviderInterface { plyrAdapter: PlyrPlayerProvider + lastPlayer = null + constructor() { this.playerAdapter = new PlayerAdapter() this.plyrAdapter = new PlyrPlayerProvider() @@ -88,7 +90,7 @@ export class Player implements PlayerProviderInterface { return null default: - return this.plyrAdapter + return this.lastPlayer = this.plyrAdapter } } @@ -96,7 +98,10 @@ export class Player implements PlayerProviderInterface { destroy() { Torrent.destroy() - this.getRightPlayer().destroy() + + if (this.lastPlayer) { + this.lastPlayer.destroy() + } } restart() { diff --git a/app/api/Player/PlayerStatuses.js b/app/api/Player/PlayerStatuses.js index 444c5383..2be47611 100644 --- a/app/api/Player/PlayerStatuses.js +++ b/app/api/Player/PlayerStatuses.js @@ -1,3 +1,4 @@ +export const NONE = 'player.status.none' export const PLAYING = 'player.status.playing' export const LOADING = 'player.status.loading' export const STREAMING = 'player.status.streaming' diff --git a/app/api/metadata/MetadataAdapter.js b/app/api/metadata/MetadataAdapter.js index 1fb3933b..ad1dba7a 100644 --- a/app/api/metadata/MetadataAdapter.js +++ b/app/api/metadata/MetadataAdapter.js @@ -4,7 +4,6 @@ */ import OpenSubtitles from 'opensubtitles-api' import { merge, resolveCache, setCache } from '../torrents/BaseTorrentProvider' -import TheMovieDbMetadataProvider from './TheMovieDBMetadataProvider' // import TraktMetadataProvider from './TraktMetadataProvider'; import type { runtimeType } from './MetadataProviderInterface' @@ -28,7 +27,7 @@ const openSubtitles = new OpenSubtitles({ function MetadataAdapter() { return [ // new TraktMetadataProvider(), - new TheMovieDbMetadataProvider() + // new TheMovieDbMetadataProvider() ] } diff --git a/app/api/metadata/PctMetadataProvider/PctMetadataHelpers.js b/app/api/metadata/PctMetadataProvider/PctMetadataHelpers.js index 5011a872..3027ff7d 100644 --- a/app/api/metadata/PctMetadataProvider/PctMetadataHelpers.js +++ b/app/api/metadata/PctMetadataProvider/PctMetadataHelpers.js @@ -17,7 +17,7 @@ export const formatImages = (images: ImageType) => { } } -export const formatTorrents = (torrents) => { +export const formatTorrents = (torrents, type = 'movie') => { const getHealth = (seed, peer) => { const ratio = seed && !!peer ? seed / peer : seed @@ -48,16 +48,43 @@ export const formatTorrents = (torrents) => { ...torrent, quality, health: { - ...getHealth(torrent.seed, torrent.peer), + ...getHealth(torrent.seed || torrent.seeds, torrent.peer || torrent.peers), }, }) + if (type === 'movie') { + return { + '1080p': !torrents['1080p'] ? null : formatTorrent(torrents['1080p'], '1080p'), + '720p' : !torrents['720p'] ? null : formatTorrent(torrents['720p'], '720p'), + } + } + return { '1080p': !torrents['1080p'] ? null : formatTorrent(torrents['1080p'], '1080p'), '720p' : !torrents['720p'] ? null : formatTorrent(torrents['720p'], '720p'), + '480p' : !torrents['480p'] ? null : formatTorrent(torrents['480p'], '480p'), } } export const formatRating = (rating: RatingType) => ({ stars: (rating.percentage / 100) * 5, }) + +export const formatShowEpisodes = (episodes) => { + let seasons = [] + + episodes.map(episode => { + if (!seasons[episode.season]) { + seasons[episode.season] = [] + } + + seasons[episode.season][episode.episode] = { + summary : episode.overview, + season : episode.season, + episode : episode.episode, + torrents: formatTorrents(episode.torrents, 'show'), + } + }) + + return seasons +} diff --git a/app/api/metadata/PctMetadataProvider/PctMetadataProvider.js b/app/api/metadata/PctMetadataProvider/PctMetadataProvider.js index ae9d423b..12e30682 100644 --- a/app/api/metadata/PctMetadataProvider/PctMetadataProvider.js +++ b/app/api/metadata/PctMetadataProvider/PctMetadataProvider.js @@ -30,7 +30,7 @@ export default class PctMetadataProvider extends BaseMetadataProvider implements getShow = (itemId: string) => ( this.popcornAPI.get(`show/${itemId}`) - .then(response => this.formatShow(response.data)) + .then(response => this.formatShow(response.data, true)) ) formatMovies = (movies: Array) => (movies.map((movie: MovieType) => this.formatMovie(movie))) @@ -66,7 +66,11 @@ export default class PctMetadataProvider extends BaseMetadataProvider implements if (isDetail) { formattedShow = { ...formattedShow, - episodes: show.episodes, + runtime : this.formatRuntimeMinutesToObject(show.runtime), + episodes: Helpers.formatShowEpisodes(show.episodes), + summary : show.synopsis, + genres : show.genres, + status : show.status, } } diff --git a/app/api/metadata/TheMovieDBMetadataProvider.js b/app/api/metadata/TheMovieDBMetadataProvider.js deleted file mode 100644 index 20ad1e98..00000000 --- a/app/api/metadata/TheMovieDBMetadataProvider.js +++ /dev/null @@ -1,265 +0,0 @@ -// @flow -import axios from 'axios'; -import { parseRuntimeMinutesToObject } from './MetadataAdapter'; -import type { MetadataProviderInterface } from './MetadataProviderInterface'; - -export default class TheMovieDbMetadataProvider implements MetadataProviderInterface { - - apiKey = '809858c82322872e2be9b2c127ccdcf7'; - - imageUri = 'https://image.tmdb.org/t/p/'; - - apiUri = 'https://api.themoviedb.org/3/'; - - genres = { - '12' : 'Adventure', - '14' : 'Fantasy', - '16' : 'Animation', - '18' : 'Drama', - '27' : 'Horror', - '28' : 'Action', - '35' : 'Comedy', - '36' : 'History', - '37' : 'Western', - '53' : 'Thriller', - '80' : 'Crime', - '99' : 'Documentary', - '878' : 'Science Fiction', - '9648' : 'Mystery', - '10402': 'Music', - '10749': 'Romance', - '10751': 'Family', - '10752': 'War', - '10770': 'TV Movie', - '10759': 'Action & Adventure', - '10762': 'Kids', - '10763': 'News', - '10764': 'Reality', - '10765': 'Sci-Fi & Fantasy', - '10766': 'Soap', - '10767': 'Talk', - '10768': 'War & Politics' - }; - - theMovieDb: axios; - - movieGenres: { - [genre: string]: string - }; - - constructor() { - this.theMovieDb = axios.create({ - baseURL: this.apiUri, - params : { - api_key : this.apiKey, - append_to_response: 'external_ids,videos' - } - }); - } - - getMovies(page: number = 1) { - return this.theMovieDb - .get('movie/popular', { params: { page } }) - .then(({ data }) => - data.results.map(movie => formatMetadata(movie, 'movies', this.imageUri, this.genres)) - ); - } - - getMovie(itemId: string) { - return this.theMovieDb - .get(`movie/${itemId}`) - .then(({ data }) => formatMetadata(data, 'movies', this.imageUri, this.genres)); - } - - getShows(page: number = 1) { - return this.theMovieDb - .get('tv/popular', { params: { page } }) - .then(({ data }) => - data.results.map(show => - formatMetadata(show, 'shows', this.imageUri, this.genres) - ) - ); - } - - getShow(itemId: string) { - return this.theMovieDb - .get(`tv/${itemId}`) - .then(({ data }) => - formatMetadata(data, 'shows', this.imageUri, this.genres) - ); - } - - getSeasons(itemId: string) { - return this.theMovieDb - .get(`tv/${itemId}`) - .then(({ data }) => formatSeasons(data)); - } - - getSeason(itemId: string, season: number) { - return this.theMovieDb - .get(`tv/${itemId}/season/${season}`) - .then(({ data }) => formatSeason(data)); - } - - getEpisode(itemId: string, season: number, episode: number) { - return this.theMovieDb - .get(`tv/${itemId}/season/${season}/episode/${episode}`) - .then(({ data }) => formatEpisode(data)); - } - - search(query: string, page: number = 1) { - return this.theMovieDb - .get('search/multi', { params: { page, include_adult: true, query } }) - .then(({ data }) => - data.results.map(result => - formatMetadata( - result, - result.media_type === 'movie' ? 'movies' : 'shows', - this.imageUri, - this.genres - ) - ) - ); - } - - getSimilar(type: string = 'movies', itemId: string, limit: number = 5) { - const urlType = (() => { - switch (type) { - case 'movies': - return 'movie'; - case 'shows': - return 'tv'; - default: { - throw new Error(`Unexpect type "${type}"`); - } - } - })(); - - return this.theMovieDb - .get(`${urlType}/${itemId}/recommendations`) - .then(({ data }) => - data.results - .map(movie => - formatMetadata(movie, 'movies', this.imageUri, this.genres) - ) - .filter((each, index) => index <= limit - 1) - ); - } - - // @TODO: Properly implement provider architecture - provide() {} -} - -function formatImage(imageUri, path: string, size: string = 'original'): string { - return `${imageUri}${size}/${path}`; -} - -function formatMetadata(item, type: string, imageUri: string, genres) { - return { - // 'title' property is on movies only. 'name' property is on - // shows only - title : item.name || item.title, - year : new Date(item.release_date).getFullYear(), - // @DEPRECATE - id : String(item.id), - ids : { - tmdbId: String(item.id), - imdbId: item.imdb_id || (item.external_ids && item.external_ids.imdb_id - ? item.external_ids.imdb_id - : '') - }, - type, - certification: 'n/a', - summary : item.overview, - genres : item.genres - ? item.genres.map(genre => genre.name) - : item.genre_ids - ? item.genre_ids.map(genre => genres[String(genre)]) - : [], - rating : item.vote_average, - runtime : item.runtime || - (item.episode_run_time && item.episode_run_time.length > 0) - ? parseRuntimeMinutesToObject(type === 'movies' ? item.runtime : item.episode_run_time[0]) - : { - full : 'n/a', - hours : 'n/a', - minutes: 'n/a' - }, - trailer : item.videos && item.videos.results && - item.videos.results.length > 0 - ? `http://youtube.com/watch?v=${item.videos.results[0].key}` - : 'n/a', - images : { - fanart: { - full : formatImage(imageUri, item.backdrop_path, 'original'), - medium: formatImage(imageUri, item.backdrop_path, 'w780'), - thumb : formatImage(imageUri, item.backdrop_path, 'w342') - }, - poster: { - full : formatImage(imageUri, item.poster_path, 'original'), - medium: formatImage(imageUri, item.poster_path, 'w780'), - thumb : formatImage(imageUri, item.poster_path, 'w342') - } - } - }; -} - -function formatSeasons(show) { - const firstSeasonIsZero = show.seasons.length > 0 - ? show.seasons[0].season_number === 0 - : false; - - return show.seasons.map(season => ({ - season : firstSeasonIsZero ? season.season_number + 1 : season.season_number, - overview: show.overview, - id : String(season.id), - ids : { - tmdbId: String(season.id) - }, - images : { - full : season.poster_path, - medium: season.poster_path, - thumb : season.poster_path - } - })); -} - -function formatSeason(season) { - return season.episodes.map(episode => ({ - id : String(episode.id), - ids : { - tmdbId: String(episode.id) - }, - title : episode.name, - season : episode.season_number, - episode : episode.episode_number, - overview: episode.overview, - rating : episode.vote_average, - // rating: episode.rating ? roundRating(episode.rating) : 'n/a', - images : { - full : episode.poster_path, - medium: episode.poster_path, - thumb : episode.poster_path - } - })); -} - -function formatEpisode(episode) { - return { - id : String(episode.id), - ids : { - tmdbId: String(episode.id) - }, - title : episode.name, - season : episode.season_number, - episode : episode.episode_number, - overview: episode.overview, - rating : episode.vote_average, - // rating: episode.rating ? roundRating(episode.rating) : 'n/a', - images : { - full : episode.still_path, - medium: episode.still_path, - thumb : episode.still_path - } - }; -} diff --git a/app/api/metadata/TraktMetadataProvider.js b/app/api/metadata/TraktMetadataProvider.js_old similarity index 100% rename from app/api/metadata/TraktMetadataProvider.js rename to app/api/metadata/TraktMetadataProvider.js_old diff --git a/app/api/metadata/TraktMetadataProvider/TraktMetadataProvider.js b/app/api/metadata/TraktMetadataProvider/TraktMetadataProvider.js new file mode 100644 index 00000000..64017186 --- /dev/null +++ b/app/api/metadata/TraktMetadataProvider/TraktMetadataProvider.js @@ -0,0 +1,206 @@ +// @flow +import fetch from 'isomorphic-fetch' +import Trakt from 'trakt.tv' +import { parseRuntimeMinutesToObject } from '../MetadataAdapter' +import type { MetadataProviderInterface } from '../MetadataProviderInterface' + +export default class TraktMetadataAdapter implements MetadataProviderInterface { + + clientId = '647c69e4ed1ad13393bf6edd9d8f9fb6fe9faf405b44320a6b71ab960b4540a2' + clientSecret = 'f55b0a53c63af683588b47f6de94226b7572a6f83f40bd44c58a7c83fe1f2cb1' + + trakt: Trakt + + constructor() { + this.trakt = new Trakt({ + client_id : this.clientId, + client_secret: this.clientSecret, + }) + } + + getMovies(page: number = 1, limit: number = 50) { + return this.trakt.movies + .popular({ + paginate: true, + page, + limit, + extended: 'full,images,metadata' + }) + .then(movies => movies.map(movie => formatMetadata(movie, 'movies'))) + } + + getMovie(itemId: string) { + return this.trakt.movies + .summary({ + id : itemId, + extended: 'full,images,metadata' + }) + .then(movie => formatMetadata(movie, 'movies')) + } + + getShows(page: number = 1, limit: number = 50) { + return this.trakt.shows + .popular({ + paginate: true, + page, + limit, + extended: 'full,images,metadata' + }) + .then(shows => shows.map(show => formatMetadata(show, 'shows'))) + } + + getShow(itemId: string) { + return this.trakt.shows + .summary({ + id : itemId, + extended: 'full,images,metadata' + }) + .then(show => formatMetadata(show, 'shows')) + } + + getSeasons(itemId: string) { + return this.trakt.seasons + .summary({ + id : itemId, + extended: 'episodes,full', + }) + + /*.then(res => + res.filter(season => season.aired_episodes !== 0).map(season => ({ + season : season.number + 1, + overview: season.overview, + id : season.ids.imdb, + images : { + full : season.images.poster.full, + medium: season.images.poster.medium, + thumb : season.images.poster.thumb + } + }))*/ + } + + getSeason(itemId: string, season: number) { + return this.trakt.seasons + .season({ + id : itemId, + season, + extended: 'full,images,metadata' + }) + .then(episodes => episodes.map(episode => formatSeason(episode))) + } + + getEpisode(itemId: string, season: number, episode: number) { + return this.trakt.episodes + .summary({ + id : itemId, + season, + episode, + extended: 'full,images,metadata' + }) + .then(res => formatSeason(res)) + } + + search(query: string, page: number = 1) { + if (!query) { + throw Error('Query paramater required') + } + + // http://www.omdbapi.com/?t=Game+of+thrones&y=&plot=short&r=json + return fetch( + `http://www.omdbapi.com/?s=${encodeURIComponent(query)}&y=&page=${page}` + ) + .then(response => response.json()) + .then(response => response.Search.map(movie => formatMovieSearch(movie))) + } + + /** + * @param {string} type | movie or show + * @param {string} itemId | movie or show + */ + getSimilar(type: string = 'movies', itemId: string, limit: number = 5) { + return this.trakt[type] + .related({ + id : itemId, + limit, + extended: 'full,images,metadata' + }) + .then(movies => movies.map(movie => formatMetadata(movie, type))) + } + + // @TODO: Properly implement provider architecture + provide() {} +} + +function formatMetadata(movie = {}, type: string) { + return { + title : movie.title, + year : movie.year, + // @DEPRECATE + id : movie.ids.imdb, + ids : { + imdbId: movie.ids.imdb + }, + type, + certification: movie.certification, + summary : movie.overview, + genres : movie.genres, + rating : movie.rating ? roundRating(movie.rating) : 'n/a', + runtime : parseRuntimeMinutesToObject(movie.runtime), + trailer : movie.trailer, + images : movie.images, + } +} + +function formatMovieSearch(movie) { + return { + title : movie.Title, + year : parseInt(movie.Year, 10), + // @DEPRECATE + id : movie.imdbID, + ids : { + imdbId: movie.imdbID + }, + type : movie.Type.includes('movie') ? 'movies' : 'shows', + certification: movie.Rated, + summary : 'n/a', // omdbapi does not support + genres : [], + rating : 'n/a', // omdbapi does not support + runtime : { + full : 'n/a', // omdbapi does not support + hours : 'n/a', // omdbapi does not support + minutes: 'n/a' // omdbapi does not support + }, + trailer : 'n/a', // omdbapi does not support + images : { + fanart: { + full : movie.Poster || '', + medium: movie.Poster || '', + thumb : movie.Poster || '' + }, + poster: { + full : movie.Poster || '', + medium: movie.Poster || '', + thumb : movie.Poster || '' + } + } + } +} + +function formatSeason(season, image: string = 'screenshot') { + return { + id : season.ids.imdb, + title : season.title, + season : season.season, + episode : season.number, + overview: season.overview, + rating : season.rating ? roundRating(season.rating) : 'n/a', + images : { + full : season.images[image].full, + medium: season.images[image].medium, + thumb : season.images[image].thumb + } + } +} + +function roundRating(rating: number): number { + return Math.round(rating * 10) / 10 +} diff --git a/app/api/metadata/TraktMetadataProvider/index.js b/app/api/metadata/TraktMetadataProvider/index.js new file mode 100644 index 00000000..6eb9051c --- /dev/null +++ b/app/api/metadata/TraktMetadataProvider/index.js @@ -0,0 +1,3 @@ +import TraktMetadataProvider from './TraktMetadataProvider' + +export default TraktMetadataProvider diff --git a/app/api/metadata/example.js b/app/api/metadata/example.js deleted file mode 100644 index afce8263..00000000 --- a/app/api/metadata/example.js +++ /dev/null @@ -1,92 +0,0 @@ -// Here is an example of the structure of a MetadataProvider -// All providers should take advantage of the Cache -// -// -// Here is an example of the structure of a MetadataProvider -// -// getMovie(itemId) {} -// -// { -// title: , -// year: , -// ids: { -// imdbId: 'tt134145', -// tmdbId: '2414140' -// } -// summary: , -// genres: , -// runtime: { -// full: , -// hours: , -// minutes: -// }, -// trailer: , A link to the trailer of the movie -// rating: , 1 - 5, round to 1 decimal place || n/a -// images: { -// fanart: { -// full: -// medium: -// thumb: -// }, -// poster: { -// full: -// medium: -// thumb: -// }, -// } -// } -// -// getMovie(itemId) {} -// -// getMovies(pageumber, limit, genre, sortMethod) {} -// -// search(searchQuery, genre, sortMethod) {} -// -// similar(itemId) {} -// -// getSeasons(itemId) {} -// -// [ -// { -// season: 1, -// images: { -// full: , -// medium: , -// thumb: -// } -// } -// ... -// ] -// -// getSeason(itemId, season) {} -// -// [ -// { -// title: 'Winter Is Coming', -// id: 'tt1480055', -// season: 1, -// episode: 1, -// rating: , 1 - 5, round to 1 decimal place || n/a -// images: { -// full: , -// medium: , -// thumb: -// } -// } -// ... -// ] -// -// getEpisode(itemId, season, episode) {} -// -// { -// title: 'Winter Is Coming', -// id: itemId, -// season: 1, -// episode: 1, -// overview: 'Ned Stark, Lord of Winterfell learns...' -// images: { -// full: , -// medium: , -// thumb: -// } -// } diff --git a/app/api/players/PlyrPlayerProvider/PlyrPlayerProvider.js b/app/api/players/PlyrPlayerProvider/PlyrPlayerProvider.js index d4ecbc01..059cacf2 100644 --- a/app/api/players/PlyrPlayerProvider/PlyrPlayerProvider.js +++ b/app/api/players/PlyrPlayerProvider/PlyrPlayerProvider.js @@ -20,7 +20,7 @@ class PlyrPlayerProvider implements PlayerProviderInterface { powerSaveBlockerId: number - status: string = null + status: string = PlayerStatuses.NONE supportedFormats = [ 'mp4', @@ -114,6 +114,9 @@ class PlyrPlayerProvider implements PlayerProviderInterface { if (this.player) { this.player.destroy() + this.player = null + + this.updateStatus(PlayerStatuses.NONE) } } diff --git a/app/api/torrents/BaseTorrentProvider.js b/app/api/torrents/BaseTorrentProvider.js index ef783f91..6efd5fbf 100644 --- a/app/api/torrents/BaseTorrentProvider.js +++ b/app/api/torrents/BaseTorrentProvider.js @@ -2,7 +2,6 @@ /* eslint prefer-template: 0 */ import cache from 'lru-cache'; import url from 'url'; -import TheMovieDbMetadataProvider from '../metadata/TheMovieDBMetadataProvider'; import type { torrentType } from './TorrentProviderInterface'; export const providerCache = cache({ @@ -72,14 +71,14 @@ export function determineQuality(magnet: string, metadata: string = ''): string } export async function convertTmdbToImdb(tmdbId: string): Promise { - const theMovieDbProvider = new TheMovieDbMetadataProvider(); + /*const theMovieDbProvider = new TheMovieDbMetadataProvider(); const movie = await theMovieDbProvider.getMovie(tmdbId); if (!movie.ids.imdbId) { throw new Error('Cannot convert tmdbId to imdbId'); } - return movie.ids.imdbId; + return movie.ids.imdbId;*/ } // export async function convertImdbtoTmdb(imdbId: string): Promise { diff --git a/app/components/Item/Background/Background.js b/app/components/Item/Background/Background.js index 18474d0a..6ef1ab47 100644 --- a/app/components/Item/Background/Background.js +++ b/app/components/Item/Background/Background.js @@ -31,7 +31,7 @@ export const Background = ({
- {showPlayInfo && ( + {showPlayInfo && activeMode === 'movie' && ( diff --git a/app/components/Item/Info/Info.js b/app/components/Item/Info/Info.js index 42f6f3a1..e2fef185 100644 --- a/app/components/Item/Info/Info.js +++ b/app/components/Item/Info/Info.js @@ -16,7 +16,7 @@ export const Info = ({ item, play }: Props) => (
- {item.runtime.short && ( + {item.runtime && item.runtime.short && (
{item.runtime.short} diff --git a/app/components/Item/Info/Info.scss b/app/components/Item/Info/Info.scss index e6443a4f..343a47aa 100644 --- a/app/components/Item/Info/Info.scss +++ b/app/components/Item/Info/Info.scss @@ -43,6 +43,7 @@ &__summary { font-weight: 100; line-height: 150%; + max-width: 600px; } } diff --git a/app/components/Item/ItemActions.js b/app/components/Item/ItemActions.js index 746894c5..10d2d3b5 100644 --- a/app/components/Item/ItemActions.js +++ b/app/components/Item/ItemActions.js @@ -22,27 +22,13 @@ export function getItem(itemId, activeMode) { switch (activeMode) { case 'movie': - getMovie(itemId).then(movie => dispatch(fetchedItem(movie))) - break + return Butter.getMovie(itemId).then(movie => dispatch(fetchedItem(movie))) case 'show': - return dispatch(fetchedItem(getShow(itemId))) + return Butter.getShow(itemId).then(show => dispatch(fetchedItem(show))) default: return null } - - return null } } - -export function getMovie(itemId) { - // TODO:: Check if the movie is not already in the fetched movies - - return Butter.getMovie(itemId) - .then(movie => movie) -} - -export function getShow(itemId) { - return Butter.getShow(itemId) -} diff --git a/app/components/Item/ItemComponent.js b/app/components/Item/ItemComponent.js index 3d973db0..0fac2d27 100644 --- a/app/components/Item/ItemComponent.js +++ b/app/components/Item/ItemComponent.js @@ -69,7 +69,7 @@ export default class Item extends React.Component { this.getAllData() window.scrollTo(0, 0) - } else if (!isLoading && wasLoading) { + } else if (!isLoading && wasLoading && newItem.type === 'movie') { this.getBestTorrent(nextProps) } } @@ -158,10 +158,12 @@ export default class Item extends React.Component { const { item, isLoading } = this.props const { torrent } = this.state - if (isLoading || item === null || !torrent) { + if (isLoading || item === null) { return null } + console.log(item) + return (
diff --git a/app/components/Player/PlayerComponent.js b/app/components/Player/PlayerComponent.js index c4397c85..482ae1c3 100644 --- a/app/components/Player/PlayerComponent.js +++ b/app/components/Player/PlayerComponent.js @@ -44,6 +44,10 @@ export class Player extends React.Component { } } + componentWillUnmount() { + MediaPlayer.destroy() + } + playerStatusChanged = (event, data) => { const { newStatus } = data const { updateStatus } = this.props