Browse Source

Trailer not on load

pull/5180/head
Ruud 10 years ago
parent
commit
7c0dcc5b2b
  1. 148
      couchpotato/core/media/movie/_base/static/movie.actions.js
  2. 25
      couchpotato/core/media/movie/_base/static/movie.js
  3. 36
      couchpotato/core/media/movie/_base/static/movie.scss
  4. 27
      couchpotato/core/media/movie/suggestion/main.py
  5. 6
      couchpotato/static/fonts/config.json
  6. BIN
      couchpotato/static/fonts/icons.eot
  7. 2
      couchpotato/static/fonts/icons.svg
  8. BIN
      couchpotato/static/fonts/icons.ttf
  9. BIN
      couchpotato/static/fonts/icons.woff
  10. 20
      couchpotato/static/scripts/page/home.js
  11. 11
      couchpotato/static/style/_fonts.scss
  12. 1
      couchpotato/static/style/main.scss

148
couchpotato/core/media/movie/_base/static/movie.actions.js

@ -453,33 +453,42 @@ MA.Trailer = new Class({
var self = this;
if(!self.player_container){
var id = 'trailer-'+randomString();
self.player_container = new Element('div.icon-play[id='+id+']', {
self.id = 'trailer-'+randomString();
self.player_container = new Element('div.icon-play[id='+self.id+']', {
'events': {
'click': function(e){
self.watch(id);
}
'click': self.watch.bind(self)
}
});
}).adopt(new Element('span[text="play"]'), new Element('span[text="trailer"]'));
self.container = new Element('div.trailer_container')
.grab(self.player_container);
}
var data_url = 'https://www.googleapis.com/youtube/v3/search?q="{title}" {year} trailer&maxResults=1&type=video&videoDefinition=high&videoEmbeddable=true&part=snippet&key=AIzaSyAT3li1KjfLidaL6Vt8T92MRU7n4VOrjYk';
return self.container;
},
watch: function(){
var self = this,
data_url = 'https://www.googleapis.com/youtube/v3/search?q="{title}" {year} trailer&maxResults=1&type=video&videoDefinition=high&videoEmbeddable=true&part=snippet&key=AIzaSyAT3li1KjfLidaL6Vt8T92MRU7n4VOrjYk';
var url = data_url.substitute({
'title': encodeURI(self.getTitle()),
'year': self.get('year')
});
var spinner = new Element('div.mask').grab(new Element('div.spinner')).inject(self.container);
new Request.JSONP({
'url': url,
'onComplete': function(json){
self.player = new YT.Player(id, {
self.player = new YT.Player(self.id, {
'height': '100%',
'width': '100%',
'videoId': json.items[0].id.videoId,
'playerVars': {
'autoplay': 1,
'showsearch': 0,
'showinfo': 0,
'wmode': 'transparent',
@ -487,25 +496,10 @@ MA.Trailer = new Class({
}
});
spinner.hide();
}
}).send();
return self.container;
},
stop: function(){
var self = this;
self.player.stopVideo();
self.container.addClass('hide');
self.close_button.addClass('hide');
$(self.movie).setStyle('height', null);
setTimeout(function(){
self.container.destroy();
self.close_button.destroy();
}, 1800);
}
@ -784,6 +778,110 @@ MA.Refresh = new Class({
});
MA.Add = new Class({
Extends: MovieAction,
create: function() {
var self = this;
self.button = self.createButton();
self.detail_button = self.createButton();
p('add');
},
createButton: function(){
var self = this;
return new Element('a.add', {
'text': 'Add movie',
'title': 'Re-add the movie and mark all previous snatched/downloaded as ignored',
'events': {
'click': self.doAdd.bind(self)
}
});
},
doAdd: function(e){
var self = this;
(e).preventDefault();
var m = new BlockSearchMovieItem(movie, {
'onAdded': function(){
//self.afterAdded(m, movie);
}
});
p(m);
}
});
MA.SuggestSeen = new Class({
Extends: MovieAction,
create: function() {
var self = this;
self.button = self.createButton();
self.detail_button = self.createButton();
},
createButton: function(){
var self = this;
return new Element('a.add', {
'text': 'Already seen',
'title': 'Already seen it!',
'events': {
'click': self.markAsSeen.bind(self)
}
});
},
markAsSeen: function(e){
var self = this;
(e).preventDefault();
}
});
MA.SuggestIgnore = new Class({
Extends: MovieAction,
create: function() {
var self = this;
self.button = self.createButton();
self.detail_button = self.createButton();
},
createButton: function(){
var self = this;
return new Element('a.add', {
'text': 'Ignore',
'title': 'Don\'t suggest this movie anymore',
'events': {
'click': self.markAsIgnored.bind(self)
}
});
},
markAsIgnored: function(e){
var self = this;
(e).preventDefault();
}
});
MA.Readd = new Class({
Extends: MovieAction,

25
couchpotato/core/media/movie/_base/static/movie.js

@ -37,8 +37,10 @@ var Movie = new Class({
self.addEvents();
//if(data.identifiers.imdb == 'tt2713180')
// self.openDetails();
if(data.identifiers.imdb == 'tt3181822'){
self.el.fireEvent('mouseenter');
self.openDetails();
}
},
openDetails: function(){
@ -204,6 +206,20 @@ var Movie = new Class({
eta_date = eta_date.toLocaleString('en-us', { month: "long" }) + ' ' + eta_date.getFullYear();
}
var thumbnail = null;
if(self.data.files && self.data.files.image_poster && self.data.files.image_poster.length > 0){
thumbnail = new Element('img', {
'class': 'type_image poster',
'src': Api.createUrl('file.cache') + self.data.files.image_poster[0].split(Api.getOption('path_sep')).pop()
});
}
else if(self.data.info && self.data.info.images && self.data.info.images.poster && self.data.info.images.poster.length > 0){
thumbnail = new Element('img', {
'class': 'type_image poster',
'src': self.data.info.images.poster[0]
});
}
self.el.adopt(
self.select_checkbox = new Element('input[type=checkbox].inlay', {
'events': {
@ -212,10 +228,7 @@ var Movie = new Class({
}
}
}),
self.thumbnail = (self.data.files && self.data.files.image_poster && self.data.files.image_poster.length > 0) ? new Element('img', {
'class': 'type_image poster',
'src': Api.createUrl('file.cache') + self.data.files.image_poster[0].split(Api.getOption('path_sep')).pop()
}): null,
self.thumbnail = thumbnail,
self.data_container = new Element('div.data.inlay.light').adopt(
self.info_container = new Element('div.info').adopt(
new Element('div.title').adopt(

36
couchpotato/core/media/movie/_base/static/movie.scss

@ -473,6 +473,11 @@
a {
display: inline-block;
padding: 0 10px 10px;
color: $primary_color;
&:hover {
color: #000;
}
}
}
@ -609,11 +614,42 @@
}
.trailer_container {
background: $theme_off;
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
cursor: pointer;
transition: all 300ms;
&:hover {
background: $primary_color;
color: #FFF;
}
.icon-play {
font-size: 22px;
position: absolute;
text-align: center;
width: 100%;
top: 50%;
transform: translateY(-50%);
span {
position: absolute;
font-size: 16px;
top: 50%;
left: 50%;
margin-left: 10px;
transform: translateY(-50%);
&:first-child {
margin-left: 0;
transform: translate(-150%, -50%);
}
}
}
iframe, object, embed {
position: absolute;

27
couchpotato/core/media/movie/suggestion/main.py

@ -1,6 +1,7 @@
import time
from couchpotato.api import addApiView
from couchpotato.core.event import fireEvent
from couchpotato.core.helpers.variable import splitString, removeDuplicate, getIdentifier
from couchpotato.core.event import fireEvent, addEvent
from couchpotato.core.helpers.variable import splitString, removeDuplicate, getIdentifier, getTitle
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
@ -15,6 +16,12 @@ class Suggestion(Plugin):
addApiView('suggestion.view', self.suggestView)
addApiView('suggestion.ignore', self.ignoreView)
def test():
time.sleep(1)
self.suggestView()
addEvent('app.load', test)
def suggestView(self, limit = 6, **kwargs):
movies = splitString(kwargs.get('movies', ''))
@ -38,10 +45,22 @@ class Suggestion(Plugin):
suggestions = fireEvent('movie.suggest', movies = movies, ignore = ignored, single = True)
self.setCache('suggestion_cached', suggestions, timeout = 6048000) # Cache for 10 weeks
medias = []
for suggestion in suggestions[:int(limit)]:
medias.append({
'status': 'suggested',
'title': getTitle(suggestion),
'type': 'movie',
'info': suggestion,
'identifiers': {
'imdb': suggestion.get('imdb')
}
})
return {
'success': True,
'count': len(suggestions),
'suggestions': suggestions[:int(limit)]
'movies': medias
}
def ignoreView(self, imdb = None, limit = 6, remove_only = False, mark_seen = False, **kwargs):

6
couchpotato/static/fonts/config.json

@ -97,6 +97,12 @@
"src": "entypo"
},
{
"uid": "cb13afd4722a849d48056540bb74c47e",
"css": "play",
"code": 59409,
"src": "entypo"
},
{
"uid": "d10920db2e79c997c5e783279291970c",
"css": "dots",
"code": 59395,

BIN
couchpotato/static/fonts/icons.eot

Binary file not shown.

2
couchpotato/static/fonts/icons.svg

@ -23,7 +23,7 @@
<glyph glyph-name="cancel" unicode="&#xe80e;" d="m724 112q0-22-15-38l-76-76q-16-15-38-15t-38 15l-164 165-164-165q-16-15-38-15t-38 15l-76 76q-16 16-16 38t16 38l164 164-164 164q-16 16-16 38t16 38l76 76q16 16 38 16t38-16l164-164 164 164q16 16 38 16t38-16l76-76q15-15 15-38t-15-38l-164-164 164-164q15-15 15-38z" horiz-adv-x="785.7" />
<glyph glyph-name="redo" unicode="&#xe80f;" d="m857 707v-250q0-14-10-25t-26-11h-250q-23 0-32 23-10 22 7 38l77 77q-82 77-194 77-58 0-111-23t-91-61-62-91-22-111 22-111 62-91 91-61 111-23q66 0 125 29t100 82q4 6 13 7 8 0 14-5l76-77q5-4 6-11t-5-13q-60-74-147-114t-182-41q-87 0-167 34t-136 92-92 137-34 166 34 166 92 137 136 92 167 34q82 0 158-31t137-88l72 72q16 18 39 8 22-9 22-33z" horiz-adv-x="857.1" />
<glyph glyph-name="ok" unicode="&#xe810;" d="m932 534q0-22-15-38l-404-404-76-76q-16-15-38-15t-38 15l-76 76-202 202q-15 16-15 38t15 38l76 76q16 16 38 16t38-16l164-165 366 367q16 16 38 16t38-16l76-76q15-16 15-38z" horiz-adv-x="1000" />
<glyph glyph-name="dropdown" unicode="&#xe811;" d="m571 457q0-14-10-25l-250-250q-11-11-25-11t-25 11l-250 250q-11 11-11 25t11 25 25 11h500q14 0 25-11t10-25z" horiz-adv-x="571.4" />
<glyph glyph-name="play" unicode="&#xe811;" d="m486 376q14-10 14-26 0-14-14-24l-428-266q-24-16-41-6t-17 40l0 514q0 30 17 40t41-6z" horiz-adv-x="500" />
</font>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
couchpotato/static/fonts/icons.ttf

Binary file not shown.

BIN
couchpotato/static/fonts/icons.woff

Binary file not shown.

20
couchpotato/static/scripts/page/home.js

@ -115,14 +115,11 @@ Page.Home = new Class({
// Coming Soon
self.suggestions_list = new MovieList({
'navigation': false,
'identifier': 'soon',
'identifier': 'suggest',
'limit': 12,
'title': 'Available soon',
'description': 'These are being searched for and should be available soon as they will be released on DVD in the next few weeks.',
'filter': {
'random': true
},
'actions': [MA.IMDB, MA.Release, MA.Trailer, MA.Refresh, MA.Delete, MA.Category, MA.Profile],
'title': 'Suggestions',
'description': 'Based on your current wanted and managed items',
'actions': [MA.Add, MA.SuggestIgnore, MA.SuggestSeen, MA.IMDB, MA.Trailer],
'load_more': false,
'view': 'thumb',
'force_view': true,
@ -134,15 +131,6 @@ Page.Home = new Class({
$(self.suggestions_list).inject(self.el);
// Suggest
//self.suggestions_list = new SuggestList({
// 'onCreated': function(){
// self.chain.callChain();
// }
//});
//
//$(self.suggestions_list).inject(self.el);
},
createCharts: function(){

11
couchpotato/static/style/_fonts.scss

@ -1,11 +1,11 @@
/* Fonts */
@font-face {
font-family: 'icons';
src: url('../fonts/icons.eot?74719539');
src: url('../fonts/icons.eot?74719539#iefix') format('embedded-opentype'),
url('../fonts/icons.woff?74719539') format('woff'),
url('../fonts/icons.ttf?74719539') format('truetype'),
url('../fonts/icons.svg?74719539#icons') format('svg');
src: url('../fonts/icons.eot?74719540');
src: url('../fonts/icons.eot?74719540#iefix') format('embedded-opentype'),
url('../fonts/icons.woff?74719540') format('woff'),
url('../fonts/icons.ttf?74719540') format('truetype'),
url('../fonts/icons.svg?74719540#icons') format('svg');
font-weight: normal;
font-style: normal;
}
@ -37,6 +37,7 @@
.icon-redo:before { content: '\e80f'; }
.icon-ok:before { content: '\e810'; }
.icon-dropdown:before { content: '\e811'; }
.icon-play:before { content: '\e811'; }
@font-face {
font-family: 'OpenSans';

1
couchpotato/static/style/main.scss

@ -82,6 +82,7 @@ input, textarea, select {
font-size: 38px;
line-height: $header_height;
height: $header_height;
opacity: .1;
transition: background 200ms $cubic;
span {

Loading…
Cancel
Save