Merge branch 'feature/AddReleaseGroupsOptions' into develop

This commit is contained in:
Adam 2015-02-15 15:48:02 +08:00
commit 33aa238060
11 changed files with 173 additions and 97 deletions

View file

@ -57,9 +57,12 @@
* Change the AniDB provider image for a sharper looking version * Change the AniDB provider image for a sharper looking version
* Change to streamline iCal function and make it handle missing network names * Change to streamline iCal function and make it handle missing network names
* Change when picking a best result to only test items that have a size specifier against the failed history * Change when picking a best result to only test items that have a size specifier against the failed history
* Add anime release groups to add new show options page
[develop changelog] [develop changelog]
* Change uT params from unicode to str.format as magnet URLs worked but sending files in POST bodies failed * Change uT params from unicode to str.format as magnet URLs worked but sending files in POST bodies failed
* Fix black and white list initialization on new show creation
* Fix validation of release groups when no group is detected
### 0.6.4 (2015-02-10 20:20:00 UTC) ### 0.6.4 (2015-02-10 20:20:00 UTC)

View file

@ -949,6 +949,11 @@ div.formpaginate {
font-weight: 900 font-weight: 900
} }
#addShowForm #blackwhitelist,
#addShowForm #blackwhitelist h4 {
font-size: 13px;
}
/* ======================================================================= /* =======================================================================
home_addExistingShow.tmpl home_addExistingShow.tmpl
========================================================================== */ ========================================================================== */

View file

@ -148,13 +148,11 @@ Separate words with a comma, e.g. "word1,word2,word3"
<br /><br /> <br /><br />
#if $show.is_anime: #if $show.is_anime:
#from sickbeard.blackandwhitelist import * #from sickbeard.blackandwhitelist import *
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_blackwhitelist.tmpl") #include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_blackwhitelist.tmpl")
<script type="text/javascript" src="$sbRoot/js/blackwhite.js?$sbPID"></script>
#end if #end if
<input type="hidden" name="whitelist" id="whitelist"/>
<input type="hidden" name="blacklist" id="blacklist"/>
<input type="submit" id="submit" value="Submit" class="btn btn-primary" /> <input type="submit" id="submit" value="Submit" class="btn btn-primary" />
</form> </form>
@ -172,21 +170,10 @@ Separate words with a comma, e.g. "word1,word2,word3"
}); });
\$("#exceptions_list").val(all_exceptions); \$("#exceptions_list").val(all_exceptions);
#if $show.is_anime:
var realvalues = []; generate_bwlist()
#end if
\$('#white option').each(function(i, selected) { });
realvalues[i] = \$(selected).val();
});
\$("#whitelist").val(realvalues.join(","));
realvalues = [];
\$('#black option').each(function(i, selected) {
realvalues[i] = \$(selected).val();
});
\$("#blacklist").val(realvalues.join(","));
});
\$('#addSceneName').click(function() { \$('#addSceneName').click(function() {
var scene_ex = \$('#SceneName').val() var scene_ex = \$('#SceneName').val()
@ -230,43 +217,6 @@ Separate words with a comma, e.g. "word1,word2,word3"
\$(this).toggle_SceneException(); \$(this).toggle_SceneException();
\$('#removeW').click(function() {
return !\$('#white option:selected').remove().appendTo('#pool');
});
\$('#addW').click(function() {
return !\$('#pool option:selected').remove().appendTo('#white');
});
\$('#addB').click(function() {
return !\$('#pool option:selected').remove().appendTo('#black');
});
\$('#removeP').click(function() {
return !\$('#pool option:selected').remove();
});
\$('#removeB').click(function() {
return !\$('#black option:selected').remove().appendTo('#pool');
});
\$('#addToWhite').click(function() {
var group = \$('#addToPoolText').attr("value")
if(group == "")
return
\$('#addToPoolText').attr("value", "")
var option = \$("<option>")
option.attr("value",group)
option.html(group)
return option.appendTo('#white');
});
\$('#addToBlack').click(function() {
var group = \$('#addToPoolText').attr("value")
if(group == "")
return
\$('#addToPoolText').attr("value", "")
var option = \$("<option>")
option.attr("value",group)
option.html(group)
return option.appendTo('#black');
});
//--> //-->
</script> </script>
</div> </div>

View file

@ -111,6 +111,7 @@
</div> </div>
<script type="text/javascript" src="$sbRoot/js/rootDirs.js?$sbPID"></script> <script type="text/javascript" src="$sbRoot/js/rootDirs.js?$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/blackwhite.js?$sbPID"></script>
</div></div> </div></div>

View file

@ -76,3 +76,6 @@
</span> </span>
</label> </label>
</div> </div>
#from sickbeard.blackandwhitelist import *
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_blackwhitelist.tmpl")

View file

@ -1,3 +1,7 @@
<div id="blackwhitelist">
<input type="hidden" name="whitelist" id="whitelist"/>
<input type="hidden" name="blacklist" id="blacklist"/>
<b>Fansub Groups:</b> <b>Fansub Groups:</b>
<div > <div >
<p>Select your preferred fansub groups from the <b>Available Groups</b> and add them to the <b>Whitelist</b>. Add groups to the <b>Blacklist</b> to ignore them.</p> <p>Select your preferred fansub groups from the <b>Available Groups</b> and add them to the <b>Whitelist</b>. Add groups to the <b>Blacklist</b> to ignore them.</p>
@ -50,4 +54,5 @@
</div> </div>
</div> </div>
<br style="clear:both" /> <br style="clear:both" />
</div>
</div> </div>

View file

@ -0,0 +1,54 @@
function generate_bwlist() {
var realvalues = [];
$('#white option').each(function(i, selected) {
realvalues[i] = $(selected).val();
});
$("#whitelist").val(realvalues.join(","));
realvalues = [];
$('#black option').each(function(i, selected) {
realvalues[i] = $(selected).val();
});
$("#blacklist").val(realvalues.join(","));
};
$('#removeW').click(function() {
!$('#white option:selected').remove().appendTo('#pool');
});
$('#addW').click(function() {
!$('#pool option:selected').remove().appendTo('#white');
});
$('#addB').click(function() {
!$('#pool option:selected').remove().appendTo('#black');
});
$('#removeP').click(function() {
!$('#pool option:selected').remove();
});
$('#removeB').click(function() {
!$('#black option:selected').remove().appendTo('#pool');
});
$('#addToWhite').click(function() {
var group = $('#addToPoolText').attr("value");
if(group == "") { return; }
$('#addToPoolText').attr("value", "");
var option = $("<option>");
option.attr("value",group);
option.html(group);
option.appendTo('#white');
});
$('#addToBlack').click(function() {
var group = $('#addToPoolText').attr("value");
if(group == "") { return; }
$('#addToPoolText').attr("value", "");
var option = $("<option>");
option.attr("value",group);
option.html(group);
option.appendTo('#black');
});

View file

@ -84,7 +84,7 @@ $(document).ready(function () {
resultStr += '<div' + rowType + '>' resultStr += '<div' + rowType + '>'
+ '<input id="whichSeries" type="radio"' + '<input id="whichSeries" type="radio"'
+ ' class="stepone-result-radio"' + ' class="stepone-result-radio"'
+ ' title="Add show <span style=\'color: rgb(66, 139, 202)\'>' + obj[4] + '</span>"' + ' title="Add show <span style=\'color: rgb(66, 139, 202)\'>' + obj[4] + '</span>"'
+ ' name="whichSeries"' + ' name="whichSeries"'
+ ' value="' + whichSeries + '"' + ' value="' + whichSeries + '"'
+ checked + checked
@ -131,6 +131,7 @@ $(document).ready(function () {
alert('You must choose a show to continue'); alert('You must choose a show to continue');
return false; return false;
} }
generate_bwlist()
$('#addShowForm').submit(); $('#addShowForm').submit();
}); });
@ -192,7 +193,7 @@ $(document).ready(function () {
} else { } else {
show_name = ''; show_name = '';
} }
update_bwlist(show_name);
var sample_text = '<p>Adding show <span class="show-name">' + show_name + '</span>' var sample_text = '<p>Adding show <span class="show-name">' + show_name + '</span>'
+ ('' == show_name ? 'into<br />' : '<br />into') + ('' == show_name ? 'into<br />' : '<br />into')
+ ' <span class="show-dest">'; + ' <span class="show-dest">';
@ -275,4 +276,34 @@ $(document).ready(function () {
}); });
}); });
$('#anime').change (function () {
updateSampleText();
myform.loadsection(2);
});
function update_bwlist (show_name) {
$('#white').children().remove();
$('#black').children().remove();
$('#pool').children().remove();
if ($('#anime').prop('checked')) {
$('#blackwhitelist').show();
if (show_name) {
$.getJSON(sbRoot + '/home/fetch_releasegroups', {'show_name': show_name}, function (data) {
if (data['result'] == 'success') {
$.each(data.groups, function(i, group) {
var option = $("<option>");
option.attr("value", group.name);
option.html(group.name + ' | ' + group.rating + ' | ' + group.range);
option.appendTo('#pool');
});
}
});
}
} else {
$('#blackwhitelist').hide();
}
};
}); });

View file

@ -16,7 +16,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. # along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
from sickbeard import db, logger import sickbeard
from sickbeard import db, logger, helpers
class BlackAndWhiteList(object): class BlackAndWhiteList(object):
@ -71,6 +72,10 @@ class BlackAndWhiteList(object):
def is_valid(self, result): def is_valid(self, result):
if not result.release_group:
logger.log('Failed to detect release group, invalid result', logger.DEBUG)
return False
if result.release_group.lower() in [x.lower() for x in self.whitelist]: if result.release_group.lower() in [x.lower() for x in self.whitelist]:
white_result = True white_result = True
else: else:
@ -88,5 +93,23 @@ class BlackAndWhiteList(object):
else: else:
return False return False
class BlackWhitelistNoShowIDException(Exception): class BlackWhitelistNoShowIDException(Exception):
'No show_id was given' 'No show_id was given'
def short_group_names(groups):
groups = groups.split(",")
shortGroupList = []
if helpers.set_up_anidb_connection():
for groupName in groups:
group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
for line in group.datalines:
if line["shortname"]:
shortGroupList.append(line["shortname"])
else:
if not groupName in shortGroupList:
shortGroupList.append(groupName)
else:
shortGroupList = groups
return shortGroupList

View file

@ -31,7 +31,6 @@ from sickbeard import name_cache
from sickbeard.exceptions import ex from sickbeard.exceptions import ex
from sickbeard.blackandwhitelist import BlackAndWhiteList from sickbeard.blackandwhitelist import BlackAndWhiteList
class ShowQueue(generic_queue.GenericQueue): class ShowQueue(generic_queue.GenericQueue):
def __init__(self): def __init__(self):
generic_queue.GenericQueue.__init__(self) generic_queue.GenericQueue.__init__(self)
@ -133,9 +132,9 @@ class ShowQueue(generic_queue.GenericQueue):
return queueItemObj return queueItemObj
def addShow(self, indexer, indexer_id, showDir, default_status=None, quality=None, flatten_folders=None, def addShow(self, indexer, indexer_id, showDir, default_status=None, quality=None, flatten_folders=None,
lang="en", subtitles=None, anime=None, scene=None, paused=None): lang="en", subtitles=None, anime=None, scene=None, paused=None, blacklist=None, whitelist=None):
queueItemObj = QueueItemAdd(indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang, queueItemObj = QueueItemAdd(indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang,
subtitles, anime, scene, paused) subtitles, anime, scene, paused, blacklist, whitelist)
self.add_item(queueItemObj) self.add_item(queueItemObj)
@ -192,7 +191,7 @@ class ShowQueueItem(generic_queue.QueueItem):
class QueueItemAdd(ShowQueueItem): class QueueItemAdd(ShowQueueItem):
def __init__(self, indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang, subtitles, anime, def __init__(self, indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang, subtitles, anime,
scene, paused): scene, paused, blacklist, whitelist):
self.indexer = indexer self.indexer = indexer
self.indexer_id = indexer_id self.indexer_id = indexer_id
@ -205,6 +204,8 @@ class QueueItemAdd(ShowQueueItem):
self.anime = anime self.anime = anime
self.scene = scene self.scene = scene
self.paused = paused self.paused = paused
self.blacklist = blacklist
self.whitelist = whitelist
self.show = None self.show = None
@ -296,6 +297,10 @@ class QueueItemAdd(ShowQueueItem):
if self.show.anime: if self.show.anime:
self.show.release_groups = BlackAndWhiteList(self.show.indexerid) self.show.release_groups = BlackAndWhiteList(self.show.indexerid)
if self.blacklist:
self.show.release_groups.set_black_keywords(self.blacklist)
if self.whitelist:
self.show.release_groups.set_white_keywords(self.whitelist)
# be smartish about this # be smartish about this
if self.show.genre and "talk show" in self.show.genre.lower(): if self.show.genre and "talk show" in self.show.genre.lower():

View file

@ -58,7 +58,7 @@ from sickbeard.scene_numbering import get_scene_numbering, set_scene_numbering,
get_xem_numbering_for_show, get_scene_absolute_numbering_for_show, get_xem_absolute_numbering_for_show, \ get_xem_numbering_for_show, get_scene_absolute_numbering_for_show, get_xem_absolute_numbering_for_show, \
get_scene_absolute_numbering get_scene_absolute_numbering
from sickbeard.blackandwhitelist import BlackAndWhiteList from sickbeard.blackandwhitelist import BlackAndWhiteList, short_group_names
from browser import WebFileBrowser from browser import WebFileBrowser
from mimetypes import MimeTypes from mimetypes import MimeTypes
@ -2871,6 +2871,9 @@ class NewHomeAddShows(MainHandler):
t.other_shows = other_shows t.other_shows = other_shows
t.provided_indexer = int(indexer or sickbeard.INDEXER_DEFAULT) t.provided_indexer = int(indexer or sickbeard.INDEXER_DEFAULT)
t.indexers = sickbeard.indexerApi().indexers t.indexers = sickbeard.indexerApi().indexers
t.whitelist = []
t.blacklist = []
t.groups = []
return _munge(t) return _munge(t)
@ -2971,6 +2974,9 @@ class NewHomeAddShows(MainHandler):
""" """
t = PageTemplate(headers=self.request.headers, file="home_addExistingShow.tmpl") t = PageTemplate(headers=self.request.headers, file="home_addExistingShow.tmpl")
t.submenu = HomeMenu() t.submenu = HomeMenu()
t.whitelist = []
t.blacklist = []
t.groups = []
return _munge(t) return _munge(t)
@ -2982,7 +2988,7 @@ class NewHomeAddShows(MainHandler):
def addNewShow(self, whichSeries=None, indexerLang="en", rootDir=None, defaultStatus=None, def addNewShow(self, whichSeries=None, indexerLang="en", rootDir=None, defaultStatus=None,
anyQualities=None, bestQualities=None, flatten_folders=None, subtitles=None, anyQualities=None, bestQualities=None, flatten_folders=None, subtitles=None,
fullShowPath=None, other_shows=None, skipShow=None, providedIndexer=None, anime=None, fullShowPath=None, other_shows=None, skipShow=None, providedIndexer=None, anime=None,
scene=None): scene=None, blacklist=None, whitelist=None):
""" """
Receive tvdb id, dir, and other options and create a show from them. If extra show dirs are Receive tvdb id, dir, and other options and create a show from them. If extra show dirs are
provided then it forwards back to newShow, if not it goes to /home. provided then it forwards back to newShow, if not it goes to /home.
@ -3065,6 +3071,11 @@ class NewHomeAddShows(MainHandler):
flatten_folders = config.checkbox_to_value(flatten_folders) flatten_folders = config.checkbox_to_value(flatten_folders)
subtitles = config.checkbox_to_value(subtitles) subtitles = config.checkbox_to_value(subtitles)
if whitelist:
whitelist = short_group_names(whitelist)
if blacklist:
blacklist = short_group_names(blacklist)
if not anyQualities: if not anyQualities:
anyQualities = [] anyQualities = []
if not bestQualities: if not bestQualities:
@ -3078,7 +3089,7 @@ class NewHomeAddShows(MainHandler):
# add the show # add the show
sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), newQuality, sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), newQuality,
flatten_folders, indexerLang, subtitles, anime, flatten_folders, indexerLang, subtitles, anime,
scene) # @UndefinedVariable scene, None, blacklist, whitelist) # @UndefinedVariable
ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir) ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir)
return finishAddShow() return finishAddShow()
@ -3862,40 +3873,15 @@ class Home(MainHandler):
if anime: if anime:
if not showObj.release_groups: if not showObj.release_groups:
showObj.release_groups = BlackAndWhiteList(showObj.indexerid) showObj.release_groups = BlackAndWhiteList(showObj.indexerid)
if whitelist: if whitelist:
whitelist = whitelist.split(",") shortwhitelist = short_group_names(whitelist)
shortWhiteList = [] showObj.release_groups.set_white_keywords(shortwhitelist)
if helpers.set_up_anidb_connection():
for groupName in whitelist:
group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
for line in group.datalines:
if line["shortname"]:
shortWhiteList.append(line["shortname"])
else:
if not groupName in shortWhiteList:
shortWhiteList.append(groupName)
else:
shortWhiteList = whitelist
showObj.release_groups.set_white_keywords(shortWhiteList)
else: else:
showObj.release_groups.set_white_keywords([]) showObj.release_groups.set_white_keywords([])
if blacklist: if blacklist:
blacklist = blacklist.split(",") shortblacklist = short_group_names(blacklist)
shortBlacklist = [] showObj.release_groups.set_black_keywords(shortblacklist)
if helpers.set_up_anidb_connection():
for groupName in blacklist:
group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
for line in group.datalines:
if line["shortname"]:
shortBlacklist.append(line["shortname"])
else:
if not groupName in shortBlacklist:
shortBlacklist.append(groupName)
else:
shortBlacklist = blacklist
showObj.release_groups.set_black_keywords(shortBlacklist)
else: else:
showObj.release_groups.set_black_keywords([]) showObj.release_groups.set_black_keywords([])
@ -4545,6 +4531,16 @@ class Home(MainHandler):
else: else:
return json.dumps({'result': 'failure'}) return json.dumps({'result': 'failure'})
@staticmethod
def fetch_releasegroups(show_name):
if helpers.set_up_anidb_connection():
anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=show_name)
groups = anime.get_groups()
return json.dumps({'result': 'success', 'groups': groups})
return json.dumps({'result': 'failure'})
class UI(MainHandler): class UI(MainHandler):
def add_message(self): def add_message(self):