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

Toggle dereferer #118

Open
wants to merge 3 commits 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
15 changes: 9 additions & 6 deletions NZBmegasearch/SuggestionModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def __init__(self, conf, cgen):
'Accept-Language': 'en-US,en;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
}
if(int(cgen['general_dereferer']) == 1):
self.dereferer = 'http://www.dereferer.org/?'
else:
self.dereferer = ''

if(int(cgen['general_trend']) == 0):
self.active_trend = 0
Expand All @@ -80,7 +84,7 @@ def ask_predb(self, args):
nuqry = args['q'] + ' ' + self.cgen['searchaddontxt']
self.qry_nologic = self.logic_expr.sub(" ",nuqry)
urlParams = dict( search=self.qry_nologic, rss=1 )
urlpredb = 'http://predb.me'
urlpredb = self.dereferer+'http://predb.me'

#~ print urlParams
try:
Expand Down Expand Up @@ -311,7 +315,7 @@ def get_trends_show(self):
return parsed_data

mxtrends = min(MAX_TRENDS, len(data))

for i in xrange(mxtrends):
toprocess = 1
if(data[i]['title'] is None):
Expand All @@ -320,13 +324,12 @@ def get_trends_show(self):
toprocess = 0
if(data[i]['ratings'] is None ):
toprocess = 0

if(toprocess):
p_data = { 'title': data[i]['title'],
'year': str(data[i]['year']),
'rating_count': data[i]['ratings']['votes'],
'tvrage_id': data[i]['tvrage_id'],
'tvdb_url': 'http://thetvdb.com/?tab=series&id='+data[i]['tvdb_id']}
'tvdb_url': self.dereferer+'http://thetvdb.com/?tab=series&id='+data[i]['tvdb_id']}
#~ print p_data
#~ print '------------------'
parsed_data.append(p_data)
Expand Down Expand Up @@ -356,7 +359,7 @@ def get_trends_movie(self):
return parsed_data

mxtrends = min(MAX_TRENDS, len(data))

for i in xrange(mxtrends):
toprocess = 1
if(data[i]['title'] is None):
Expand All @@ -372,7 +375,7 @@ def get_trends_movie(self):
p_data = { 'title': data[i]['title'],
'year': str(data[i]['year']),
'rating_count': data[i]['ratings']['votes'],
'imdb_url': 'http://www.imdb.com/title/'+data[i]['imdb_id'],
'imdb_url': self.dereferer+'http://www.imdb.com/title/'+data[i]['imdb_id'],
'release_date':data[i]['released']}
#~ print p_data
#~ print '------------------'
Expand Down
1 change: 1 addition & 0 deletions NZBmegasearch/builtin_params.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ max_cache_age = 5
max_cache_qty = 10
searchaddontxt =
revproxy =
general_dereferer = 1
13 changes: 11 additions & 2 deletions NZBmegasearch/config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def write(self, request_form):
parser.set('general', 'cache_active', '0')
parser.set('general', 'general_ipaddress', '')
parser.set('general', 'predb_active', '0')
parser.set('general', 'general_restrictopt1', '0')
parser.set('general', 'general_restrictopt1', '0')
parser.set('general', 'general_dereferer', '0')


if (request_form['general_ipaddress'] != 'AUTO'):
Expand All @@ -115,6 +116,8 @@ def write(self, request_form):
parser.set('general', 'general_https', '1')
if (request_form.has_key('general_restrictopt1') == True):
parser.set('general', 'general_restrictopt1', '1')
if (request_form.has_key('general_dereferer') == True):
parser.set('general', 'general_dereferer', '1')
if (request_form.has_key('trends') == True):
parser.set('general', 'trends', '1')
if (request_form.has_key('sugg') == True):
Expand Down Expand Up @@ -368,6 +371,7 @@ def read_conf_general(self, forcedcustom=''):
'nzbget_url' : '', 'nzbget_user':'','nzbget_pwd':'',
'general_apikey' : '',
'general_restrictopt1' : 0,
'general_dereferer' : 1,
'predb_active' : 1,
'revproxy':revproxy,
'stats_key' : gen_stats_key, 'motd':gen_motd}
Expand Down Expand Up @@ -459,6 +463,8 @@ def read_conf_custom(self, forcedcustom=''):
self.cgen['predb_active'] = cst_parser.getint('general', 'predb_active')
if(cst_parser.has_option('general' ,'general_restrictopt1')):
self.cgen['general_restrictopt1'] = cst_parser.getint('general', 'general_restrictopt1')
if(cst_parser.has_option('general' ,'general_dereferer')):
self.cgen['general_dereferer'] = cst_parser.getint('general', 'general_dereferer')
if(cst_parser.has_option('general' ,'revproxy')):
self.cgen['revproxy'] = cst_parser.get('general', 'revproxy')

Expand Down Expand Up @@ -668,13 +674,16 @@ def html_editpage(self):
genopt['smartsearch_verbose'] = ''
genopt['max_cache_verbose'] = ''
genopt['predb_active_verbose'] = ''
genopt['general_restrictopt1_verbose'] = ''
genopt['general_restrictopt1_verbose'] = ''
genopt['general_dereferer_verbose'] = ''
if(genopt['predb_active'] == 1):
genopt['predb_active_verbose'] = 'checked=yes'
if(genopt['general_https'] == 1):
genopt['general_https_verbose'] = 'checked=yes'
if(genopt['general_restrictopt1'] == 1):
genopt['general_restrictopt1_verbose'] = 'checked=yes'
if(genopt['general_dereferer'] == 1):
genopt['general_dereferer_verbose'] = 'checked=yes'
if(genopt['general_suggestion'] == 1):
genopt['general_suggestion_verbose'] = 'checked=yes'
if(genopt['general_trend'] == 1):
Expand Down
5 changes: 5 additions & 0 deletions NZBmegasearch/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@

</tr>

<tr>
<td><input type="checkbox" name="general_dereferer" id="general_dereferer" {{ genopt['general_dereferer_verbose'] }} ><label for="general_dereferer">Prefix third-party links with dereferer</label></td><td></td>

</tr>

<tr class='config_table_opts_nonhover'>
<td> <br>Authentication (optional) </td><td></td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions NZBmegasearch/templates/main_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
{% for tm in trend_movie -%}
<tr>
<td>
<a href="http://www.dereferer.org/?{{ tm['imdb_url'] }}" ><img src="static/imdb.png" width="16" height="16" alt="IMDb" /></a>
<a href="{{ tm['imdb_url'] }}" ><img src="static/imdb.png" width="16" height="16" alt="IMDb" /></a>
&nbsp;<a href="s?q={{ tm['searchstr'] }}" class='sugglinx'>{{ tm['prettytxt'] }}</a>
</td>
</tr>
Expand All @@ -108,7 +108,7 @@
{% for ts in trend_show -%}
<tr>
<td>
<a href="http://www.dereferer.org/?{{ ts['imdb_url'] }}"><img src="static/thetvdb16.png" width="16" height="16" alt="tvdb" /></a>
<a href="{{ ts['imdb_url'] }}"><img src="static/thetvdb16.png" width="16" height="16" alt="tvdb" /></a>
&nbsp;<a href="s?q={{ ts['searchstr'] }}" class='sugglinx'>{{ ts['prettytxt'] }}</a>
</td>
</tr>
Expand Down