Merge branch 'develop' of github.com:RuudBurger/CouchPotatoServer into develop
This commit is contained in:
commit
4faa617039
4 files changed
+48
-18
No files matched your search
@@ -1,20 +1,19 @@
|
|||||||
from base64 import b16encode, b32decode
|
from base64 import b16encode, b32decode
|
||||||
from datetime import timedelta
|
|
||||||
from hashlib import sha1
|
|
||||||
import shutil
|
|
||||||
from couchpotato.core.helpers.encoding import ss
|
|
||||||
from rtorrent.err import MethodError
|
|
||||||
|
|
||||||
from bencode import bencode, bdecode
|
from bencode import bencode, bdecode
|
||||||
from couchpotato.core.downloaders.base import Downloader, StatusList
|
from couchpotato.core.downloaders.base import Downloader, StatusList
|
||||||
|
from couchpotato.core.helpers.encoding import ss
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
|
from datetime import timedelta
|
||||||
|
from hashlib import sha1
|
||||||
from rtorrent import RTorrent
|
from rtorrent import RTorrent
|
||||||
|
from rtorrent.err import MethodError
|
||||||
|
import shutil
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
class rTorrent(Downloader):
|
class rTorrent(Downloader):
|
||||||
|
|
||||||
protocol = ['torrent', 'torrent_magnet']
|
protocol = ['torrent', 'torrent_magnet']
|
||||||
rt = None
|
rt = None
|
||||||
|
|
||||||
@@ -194,7 +193,7 @@ class rTorrent(Downloader):
|
|||||||
if torrent is None:
|
if torrent is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
torrent.erase() # just removes the torrent, doesn't delete data
|
torrent.erase() # just removes the torrent, doesn't delete data
|
||||||
|
|
||||||
if delete_files:
|
if delete_files:
|
||||||
shutil.rmtree(item['folder'], True)
|
shutil.rmtree(item['folder'], True)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from couchpotato.api import addApiView
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.variable import splitString
|
from couchpotato.core.helpers.variable import splitString
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Movie
|
from couchpotato.core.settings.model import Movie, Library
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
from sqlalchemy.orm import joinedload_all
|
from sqlalchemy.orm import joinedload_all
|
||||||
from sqlalchemy.sql.expression import or_
|
from sqlalchemy.sql.expression import or_
|
||||||
@@ -20,6 +20,7 @@ class Suggestion(Plugin):
|
|||||||
|
|
||||||
movies = splitString(kwargs.get('movies', ''))
|
movies = splitString(kwargs.get('movies', ''))
|
||||||
ignored = splitString(kwargs.get('ignored', ''))
|
ignored = splitString(kwargs.get('ignored', ''))
|
||||||
|
seen = splitString(kwargs.get('seen', ''))
|
||||||
|
|
||||||
cached_suggestion = self.getCache('suggestion_cached')
|
cached_suggestion = self.getCache('suggestion_cached')
|
||||||
if cached_suggestion:
|
if cached_suggestion:
|
||||||
@@ -35,6 +36,8 @@ class Suggestion(Plugin):
|
|||||||
|
|
||||||
if not ignored or len(ignored) == 0:
|
if not ignored or len(ignored) == 0:
|
||||||
ignored = splitString(Env.prop('suggest_ignore', default = ''))
|
ignored = splitString(Env.prop('suggest_ignore', default = ''))
|
||||||
|
if not seen or len(seen) == 0:
|
||||||
|
movies.extend(splitString(Env.prop('suggest_seen', default = '')))
|
||||||
|
|
||||||
suggestions = fireEvent('movie.suggest', movies = movies, ignore = ignored, single = True)
|
suggestions = fireEvent('movie.suggest', movies = movies, ignore = ignored, single = True)
|
||||||
self.setCache('suggestion_cached', suggestions, timeout = 6048000) # Cache for 10 weeks
|
self.setCache('suggestion_cached', suggestions, timeout = 6048000) # Cache for 10 weeks
|
||||||
@@ -45,17 +48,21 @@ class Suggestion(Plugin):
|
|||||||
'suggestions': suggestions[:int(limit)]
|
'suggestions': suggestions[:int(limit)]
|
||||||
}
|
}
|
||||||
|
|
||||||
def ignoreView(self, imdb = None, limit = 6, remove_only = False, **kwargs):
|
def ignoreView(self, imdb = None, limit = 6, remove_only = False, mark_seen = False, **kwargs):
|
||||||
|
|
||||||
ignored = splitString(Env.prop('suggest_ignore', default = ''))
|
ignored = splitString(Env.prop('suggest_ignore', default = ''))
|
||||||
|
seen = splitString(Env.prop('suggest_seen', default = ''))
|
||||||
|
|
||||||
new_suggestions = []
|
new_suggestions = []
|
||||||
if imdb:
|
if imdb:
|
||||||
if not remove_only:
|
if mark_seen:
|
||||||
|
seen.append(imdb)
|
||||||
|
Env.prop('suggest_seen', ','.join(set(seen)))
|
||||||
|
elif not remove_only:
|
||||||
ignored.append(imdb)
|
ignored.append(imdb)
|
||||||
Env.prop('suggest_ignore', ','.join(set(ignored)))
|
Env.prop('suggest_ignore', ','.join(set(ignored)))
|
||||||
|
|
||||||
new_suggestions = self.updateSuggestionCache(ignore_imdb = imdb, limit = limit, ignored = ignored)
|
new_suggestions = self.updateSuggestionCache(ignore_imdb = imdb, limit = limit, ignored = ignored, seen = seen)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'result': True,
|
'result': True,
|
||||||
@@ -63,12 +70,13 @@ class Suggestion(Plugin):
|
|||||||
'suggestions': new_suggestions[limit - 1:limit]
|
'suggestions': new_suggestions[limit - 1:limit]
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateSuggestionCache(self, ignore_imdb = None, limit = 6, ignored = None):
|
def updateSuggestionCache(self, ignore_imdb = None, limit = 6, ignored = None, seen = None):
|
||||||
|
|
||||||
# Combine with previous suggestion_cache
|
# Combine with previous suggestion_cache
|
||||||
cached_suggestion = self.getCache('suggestion_cached')
|
cached_suggestion = self.getCache('suggestion_cached')
|
||||||
new_suggestions = []
|
new_suggestions = []
|
||||||
ignored = [] if not ignored else ignored
|
ignored = [] if not ignored else ignored
|
||||||
|
seen = [] if not seen else seen
|
||||||
|
|
||||||
if ignore_imdb:
|
if ignore_imdb:
|
||||||
for cs in cached_suggestion:
|
for cs in cached_suggestion:
|
||||||
@@ -78,10 +86,15 @@ class Suggestion(Plugin):
|
|||||||
# Get new results and add them
|
# Get new results and add them
|
||||||
if len(new_suggestions) - 1 < limit:
|
if len(new_suggestions) - 1 < limit:
|
||||||
|
|
||||||
|
active_status, done_status = fireEvent('status.get', ['active', 'done'], single = True)
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
active_movies = db.query(Movie) \
|
active_movies = db.query(Movie) \
|
||||||
.filter(or_(*[Movie.status.has(identifier = s) for s in ['active', 'done']])).all()
|
.join(Library) \
|
||||||
movies = [x.library.identifier for x in active_movies]
|
.with_entities(Library.identifier) \
|
||||||
|
.filter(Movie.status_id.in_([active_status.get('id'), done_status.get('id')])).all()
|
||||||
|
movies = [x[0] for x in active_movies]
|
||||||
|
movies.extend(seen)
|
||||||
|
|
||||||
ignored.extend([x.get('imdb') for x in cached_suggestion])
|
ignored.extend([x.get('imdb') for x in cached_suggestion])
|
||||||
suggestions = fireEvent('movie.suggest', movies = movies, ignore = list(set(ignored)), single = True)
|
suggestions = fireEvent('movie.suggest', movies = movies, ignore = list(set(ignored)), single = True)
|
||||||
|
|||||||
@@ -105,7 +105,7 @@
|
|||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
display: none;
|
display: none;
|
||||||
width: 120px;
|
width: 140px;
|
||||||
}
|
}
|
||||||
.suggestions .movie_result:hover .actions {
|
.suggestions .movie_result:hover .actions {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@@ -26,6 +26,20 @@ var SuggestList = new Class({
|
|||||||
'onComplete': self.fill.bind(self)
|
'onComplete': self.fill.bind(self)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
'click:relay(a.eye-open)': function(e, el){
|
||||||
|
(e).stop();
|
||||||
|
|
||||||
|
$(el).getParent('.movie_result').destroy();
|
||||||
|
|
||||||
|
Api.request('suggestion.ignore', {
|
||||||
|
'data': {
|
||||||
|
'imdb': el.get('data-seen'),
|
||||||
|
'mark_seen': 1
|
||||||
|
},
|
||||||
|
'onComplete': self.fill.bind(self)
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).grab(
|
}).grab(
|
||||||
@@ -43,7 +57,7 @@ var SuggestList = new Class({
|
|||||||
fill: function(json){
|
fill: function(json){
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if(!json) return;
|
if(!json) return;
|
||||||
|
|
||||||
Object.each(json.suggestions, function(movie){
|
Object.each(json.suggestions, function(movie){
|
||||||
@@ -69,6 +83,10 @@ var SuggestList = new Class({
|
|||||||
new Element('a.delete.icon2', {
|
new Element('a.delete.icon2', {
|
||||||
'title': 'Don\'t suggest this movie again',
|
'title': 'Don\'t suggest this movie again',
|
||||||
'data-ignore': movie.imdb
|
'data-ignore': movie.imdb
|
||||||
|
}),
|
||||||
|
new Element('a.eye-open.icon2', {
|
||||||
|
'title': 'Seen it, like it, don\'t add',
|
||||||
|
'data-seen': movie.imdb
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -88,7 +106,7 @@ var SuggestList = new Class({
|
|||||||
$(m).inject(self.el);
|
$(m).inject(self.el);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
self.fireEvent('loaded');
|
self.fireEvent('loaded');
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user