Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show MPAA rating under quick infos. #556

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script>window.__startTime = (new Date()*1);</script>
<link rel="stylesheet" type="text/css" href="css/app.css">
<link rel="stylesheet" type="text/css" href="js/vendor/video-js/video-js.css">

</head>
<body>

Expand All @@ -20,7 +20,7 @@
</nav>
<h1>Popcorn Time</h1>
</header>

<div id="notification"></div>

<div id="catalog-select">
Expand All @@ -31,7 +31,7 @@ <h1>Popcorn Time</h1>

<h4 data-translate="movies">Movies</h4>
<ul class="categories">

</ul>
</div>

Expand Down Expand Up @@ -85,8 +85,14 @@ <h2><%= title %></h2>
<span class="duration"><%= runtime %> <%= i18n.__('durationUnit') %></span>
<% } %>
</li>

<% if (this.model.get('ageRating')) { %>
<li class="age-rating <%= ageRating %>">
<%= ageRating %>
</li>
<% } %>
</ul>

<i data-placement="left" data-toggle="tooltip" title="<%= health %> health" class="health <%= health %> fa fa-flash"></i>

<% var p_rating = this.model.get('voteAverage') ? this.model.get('voteAverage').toFixed(1) : 0.0 %>
Expand Down Expand Up @@ -143,7 +149,7 @@ <h4><%= i18n.__('subtitledIn') %></h4>
</div>

<div id="video-container"></div>

<div class="popcorn-disclaimer hidden">
<div class="wrapper">
<span class="text" data-translate="legalDisclaimer"></span>
Expand All @@ -153,7 +159,7 @@ <h4><%= i18n.__('subtitledIn') %></h4>
<a class="btn confirmation continue" data-translate="legalDisclaimerAccept"></a>
</div>
</div>


<!-- Basic Dependencies -->
<script src="js/vendor/jquery-2.1.0.min.js"></script>
Expand Down
25 changes: 21 additions & 4 deletions js/frontend/models/movie.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
App.Model.Movie = Backbone.Model.extend({

buildBasicView: function () {

var model = this;

// This is mostly used for reporting
Expand All @@ -11,7 +11,7 @@ App.Model.Movie = Backbone.Model.extend({
model.view = new App.View.MovieListItem({
model: model
});

model.trigger('rottenloaded');
},

Expand All @@ -20,7 +20,7 @@ App.Model.Movie = Backbone.Model.extend({
var model = this;

App.findMovieInfo(model.get('imdb'), function (data) {

model.set('infoLoaded', true);
model.set('image', data.image);
model.set('bigImage', data.image);
Expand Down Expand Up @@ -57,9 +57,26 @@ App.Model.Movie = Backbone.Model.extend({
this.buildBasicView();
//this.setRottenInfo();
//this.setSubtitles();
this.getAgeRating();
this.calculateTorrentHealth();
},

getAgeRating: function() {
// Requests the MPAA rating of the movie

var model = this;
var rating_url = 'http://www.omdbapi.com/?i=' + model.get('imdb');
var request = require("request");

request(rating_url, function(error, response, body) {
if (!error) {
model.set('ageRating', JSON.parse(body).Rated);
} else {
console.log(error);
}
});
},

calculateTorrentHealth: function () {
// Calculates the "health" of the torrent (how easy it is to stream)
var seeders = this.get('seeders');
Expand Down Expand Up @@ -91,4 +108,4 @@ App.Model.Movie = Backbone.Model.extend({
}
}

});
});