parent
ec9a7f5c8e
commit
599f4907f4
@ -1,4 +1,5 @@
|
||||
.heart {
|
||||
.image {
|
||||
align-content: center;
|
||||
margin-right: 5px;
|
||||
color: $themeRed;
|
||||
vertical-align: -0.125em;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,5 @@
|
||||
.imdb {
|
||||
align-content: center;
|
||||
margin-right: 5px;
|
||||
vertical-align: -0.125em;
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,5 @@
|
||||
.image {
|
||||
align-content: center;
|
||||
margin-right: 5px;
|
||||
vertical-align: -0.125em;
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { PureComponent } from 'react';
|
||||
import styles from './RottenTomatoRating.css';
|
||||
|
||||
class RottenTomatoRating extends PureComponent {
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
|
||||
const {
|
||||
ratings,
|
||||
hideIcon,
|
||||
iconSize
|
||||
} = this.props;
|
||||
|
||||
const rtRotten = 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNTYwIDU2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNDQ1LjE4NSA0NDQuNjg0Yy03OS4zNjkgNC4xNjctOTUuNTg3LTg2LjY1Mi0xMjYuNzI2LTg2LjAwNi0xMy4yNjguMjc5LTIzLjcyNiAxNC4xNTEtMTkuMTMzIDMwLjMyIDIuNTI1IDguODg4IDkuNTMgMjEuOTIzIDEzLjk0NCAzMC4wMTEgMTUuNTcgMjguNTQ0LTcuNDQ3IDYwLjg0NS0zNC4zODMgNjMuNTc3LTQ0Ljc2IDQuNTQtNjMuNDMzLTIxLjQyNi02Mi4yNzgtNDguMDA3IDEuMy0yOS44NCAyNi42LTYwLjMzMS42NS03My4zMDUtMjcuMTk0LTEzLjU5Ny00OS4zMDEgMzkuNTcyLTc1LjMyNSA1MS40M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ingString = '0%';
|
||||
|
||||
if (rating) {
|
||||
ratingString = `${rating.value}%`;
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
{
|
||||
!hideIcon &&
|
||||
<img
|
||||
className={styles.image}
|
||||
src={rating.value > 50 ? rtFresh : rtRotten}
|
||||
style={{
|
||||
height: `${iconSize}px`
|
||||
}}
|
||||
/>
|
||||
}
|
||||
|
||||
{ratingString}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RottenTomatoRating.propTypes = {
|
||||
ratings: PropTypes.object.isRequired,
|
||||
iconSize: PropTypes.number.isRequired,
|
||||
hideIcon: PropTypes.bool
|
||||
};
|
||||
|
||||
RottenTomatoRating.defaultProps = {
|
||||
iconSize: 14
|
||||
};
|
||||
|
||||
export default RottenTomatoRating;
|
@ -0,0 +1,5 @@
|
||||
.tmdb {
|
||||
align-content: center;
|
||||
margin-right: 5px;
|
||||
vertical-align: -0.125em;
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { PureComponent } from 'react';
|
||||
import styles from './TmdbRating.css';
|
||||
|
||||
class TmdbRating extends PureComponent {
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
|
||||
const {
|
||||
ratings,
|
||||
hideIcon,
|
||||
iconSize
|
||||
} = this.props;
|
||||
|
||||
const tmdbImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOTAuMjQgODEuNTIiPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeTE9IjQwLjc2IiB4Mj0iMTkwLjI0IiB5Mj0iNDAuNzYiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiM5MGNlYTEiLz48c3RvcCBvZmZzZXQ9Ii41NiIgc3RvcC1jb2xvcj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MS4xOCAzLjExIDMuMTEgMCAwMS42MyAyIDMuNzEgMy43MSAwIDAxLS40MyAxLjkyeiIgZmlsbD0idXJsKCNhKSIvPjwvc3ZnPg==';
|
||||
|
||||
const rating = ratings.tmdb;
|
||||
|
||||
let ratingString = '0%';
|
||||
|
||||
if (rating) {
|
||||
ratingString = `${rating.value * 10}%`;
|
||||
}
|
||||
|
||||
return (
|
||||
<span title={`${rating.votes} votes`}>
|
||||
{
|
||||
!hideIcon &&
|
||||
<img
|
||||
className={styles.image}
|
||||
src={tmdbImage}
|
||||
style={{
|
||||
height: `${iconSize}px`
|
||||
}}
|
||||
/>
|
||||
}
|
||||
|
||||
{ratingString}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
TmdbRating.propTypes = {
|
||||
ratings: PropTypes.object.isRequired,
|
||||
iconSize: PropTypes.number.isRequired,
|
||||
hideIcon: PropTypes.bool
|
||||
};
|
||||
|
||||
TmdbRating.defaultProps = {
|
||||
iconSize: 14
|
||||
};
|
||||
|
||||
export default TmdbRating;
|
@ -0,0 +1,107 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Dapper;
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(206)]
|
||||
public class multiple_ratings_support : NzbDroneMigrationBase
|
||||
{
|
||||
private readonly JsonSerializerOptions _serializerSettings;
|
||||
|
||||
public multiple_ratings_support()
|
||||
{
|
||||
_serializerSettings = new JsonSerializerOptions
|
||||
{
|
||||
AllowTrailingCommas = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
DictionaryKeyPolicy = JsonNamingPolicy.CamelCase,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = true
|
||||
};
|
||||
}
|
||||
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Execute.Sql("UPDATE CustomFilters SET Filters = Replace(Filters, 'ratings', 'tmdbRating') WHERE Type = 'discoverMovie';");
|
||||
Execute.Sql("UPDATE CustomFilters SET Filters = Replace(Filters, 'ratings', 'tmdbRating') WHERE Type = 'movieIndex';");
|
||||
|
||||
Execute.WithConnection((conn, tran) => FixRatings(conn, tran, "Movies"));
|
||||
Execute.WithConnection((conn, tran) => FixRatings(conn, tran, "ImportListMovies"));
|
||||
}
|
||||
|
||||
private void FixRatings(IDbConnection conn, IDbTransaction tran, string table)
|
||||
{
|
||||
var rows = conn.Query<Movie205>($"SELECT Id, Ratings FROM {table}");
|
||||
|
||||
var corrected = new List<Movie206>();
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var oldRatings = JsonSerializer.Deserialize<Ratings205>(row.Ratings, _serializerSettings);
|
||||
|
||||
var newRatings = new Ratings206
|
||||
{
|
||||
Tmdb = new RatingChild206
|
||||
{
|
||||
Votes = oldRatings.Votes,
|
||||
Value = oldRatings.Value,
|
||||
Type = RatingType206.User
|
||||
}
|
||||
};
|
||||
|
||||
corrected.Add(new Movie206
|
||||
{
|
||||
Id = row.Id,
|
||||
Ratings = JsonSerializer.Serialize(newRatings, _serializerSettings)
|
||||
});
|
||||
}
|
||||
|
||||
var updateSql = $"UPDATE {table} SET Ratings = @Ratings WHERE Id = @Id";
|
||||
conn.Execute(updateSql, corrected, transaction: tran);
|
||||
}
|
||||
|
||||
private class Movie205
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Ratings { get; set; }
|
||||
}
|
||||
|
||||
private class Ratings205
|
||||
{
|
||||
public int Votes { get; set; }
|
||||
public decimal Value { get; set; }
|
||||
}
|
||||
|
||||
private class Movie206
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Ratings { get; set; }
|
||||
}
|
||||
|
||||
private class Ratings206
|
||||
{
|
||||
public RatingChild206 Tmdb { get; set; }
|
||||
public RatingChild206 Imdb { get; set; }
|
||||
public RatingChild206 Metacritic { get; set; }
|
||||
public RatingChild206 RottenTomatoes { get; set; }
|
||||
}
|
||||
|
||||
private class RatingChild206
|
||||
{
|
||||
public int Votes { get; set; }
|
||||
public decimal Value { get; set; }
|
||||
public RatingType206 Type { get; set; }
|
||||
}
|
||||
|
||||
private enum RatingType206
|
||||
{
|
||||
User
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue