SOLVED Couchpotato - binsearch returning 403 - Forbidden solution

Status
Not open for further replies.

DmcDenissen

Cadet
Joined
Jul 2, 2016
Messages
4
Hi People,
Don't know if this is the right place. I finally got freenas (9.10stable) and I was installing some stuff like sabnzbd and couchpotato besides having problems and solving them for user permissions and stuff I encountered an error wenn I was searching within couchpotato it did nothing (I only setup usenet no torrents).

Wenn I looked at the logs I saw that there were 403 errors returning from the searches couchpotato did on binsearch. something like this:
ERROR [hpotato.core.plugins.base] Failed opening url in BinSearch .....

So Iooked at the query and found out that it used: minsize and maxsize as query variables but they needed to be xminsize and xmaxsize so I looked within the jail and after search for binsearch.py I edited it so I was using these vars instead of the ones without the x and couchpotato ran again. Maybe some have the same problem and now have a solution, these where the steps:

  • I logged in into my NAS through SSH (putty, and you need to enable the SSH service within your freenas box and configure it so it takes your root login)
  • After that I located the binsearch file:
    (mine was in: /mnt/[YOUR DATASET NAME]/jails/couchpotato_1/usr/pbi/couchpotato-amd64/share/couchpotato/CouchPotatoServer/couchpotato/core/media/movie/providers/nzb/binsearch.py)
    Code:
    locate binsearch.py

  • so typed:
    Code:
    cd /mnt/[YOUR DATASET NAME]/jails/couchpotato_1/usr/pbi/couchpotato-amd64/share/couchpotato/CouchPotatoServer/couchpotato/core/media/movie/providers/nzb/

  • then I gave it write permissions and changed the owner (don't know if it was needed but ok)
    (for changing ownership)
    Code:
    chown root:wheel binsearch.py

    (to change file rights)
    Code:
    chmod 777 binsearch.py

  • After that I edited the file with the vi editor (You need to lookup the commands to edit)
    Code:
    vi binsearch.py

  • I changed the vars minsize to xminsize and maxsize to xmaxsize, and saved
  • After that I returned the file to the media owner and back to read rights only:
    Code:
    chown media:media binsearch.py

    Code:
    chmod 444 binsearch.py

  • then I restarted the jail through the freenas webadmin
  • AND It worked !
I hope some of you can use this, and hopefully it works for you to, thought why not share it with the community ;)
 

Roeffus

Cadet
Joined
Apr 22, 2016
Messages
9
Incredible! Just run in to it! Thank you for the quick fix!

Btw it is also possible to use the Shell on the Freenas web environment. Then you are directly root and the filepath for binsearch.py will be the same for everybody (/usr/pbi/couchpotato-amd64/share/couchpotato/CouchPotatoServer/couchpotato/core/media/movie/providers/nzb/). Then just use edit binsearch.py.

You should address this on the couchpotato git!
 

trigun92600

Cadet
Joined
Jul 2, 2017
Messages
1
Hello,

Thanks for your post.
I've got the same issu, but in binsearch.py file, I do not have any minsize ou maxsize....
Could you help me?

Here my binsearch.py file:


import re
import traceback

from bs4 import BeautifulSoup
from couchpotato.core.helpers.variable import tryInt, simplifyString
from couchpotato.core.logger import CPLog
from couchpotato.core.media._base.providers.nzb.base import NZBProvider


log = CPLog(__name__)


class Base(NZBProvider):

urls = {
'download': 'https://www.binsearch.info/fcgi/nzb.fcgi?q=%s',
'detail': 'https://www.binsearch.info%s',
'search': 'https://www.binsearch.info/index.php?%s',
}

http_time_between_calls = 4 # Seconds

def _search(self, media, quality, results):

data = self.getHTMLData(self.urls['search'] % self.buildUrl(media, quality))

if data:
try:
html = BeautifulSoup(data)
main_table = html.find('table', attrs = {'id': 'r2'})

if not main_table:
return

items = main_table.find_all('tr')

for row in items:
title = row.find('span', attrs = {'class': 's'})

if not title: continue

nzb_id = row.find('input', attrs = {'type': 'checkbox'})['name']
info = row.find('span', attrs = {'class':'d'})
size_match = re.search('size:.(?P<size>[0-9\.]+.[GMB]+)', info.text)

age = 0
try: age = re.search('(?P<size>\d+d)', row.find_all('td')[-1:][0].text).group('size')[:-1]
except: pass

def extra_check(item):
parts = re.search('available:.(?P<parts>\d+)./.(?P<total>\d+)', info.text)
total = float(tryInt(parts.group('total')))
parts = float(tryInt(parts.group('parts')))

if (total / parts) < 1 and ((total / parts) < 0.95 or ((total / parts) >= 0.95 and not ('par2' in info.text.lower() or 'pa3' in info.text.lower()))):
log.info2('Wrong: \'%s\', not complete: %s out of %s', (item['name'], parts, total))
return False

if 'requires password' in info.text.lower():
log.info2('Wrong: \'%s\', passworded', (item['name']))
return False

return True

results.append({
'id': nzb_id,
'name': simplifyString(title.text),
'age': tryInt(age),
'size': self.parseSize(size_match.group('size')),
'url': self.urls['download'] % nzb_id,
'detail_url': self.urls['detail'] % info.find('a')['href'],
'extra_check': extra_check
})

except:
log.error('Failed to parse HTML response from BinSearch: %s', traceback.format_exc())

def download(self, url = '', nzb_id = ''):

data = {
'action': 'nzb',
nzb_id: 'on'
}

try:
return self.urlopen(url, data = data, show_error = False)
except:
log.error('Failed getting nzb from %s: %s', (self.getName(), traceback.format_exc()))

return 'try_next'


config = [{
'name': 'binsearch',
'groups': [
{
'tab': 'searcher',
'list': 'nzb_providers',
'name': 'binsearch',
'description': 'Free provider, less accurate. See <a href="https://www.binsearch.info/" target="_blank">BinSearch</a>',
'wizard': True,
'icon': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAATklEQVQY02NwQAMMWAXOnz+PKvD//3/CAvM//z+fgiwAAs+RBab4PP//vwbFjPlAffgEChzOo2r5fBuIfRAC5w8D+QUofkkp8MHjOWQAAM3Sbogztg2wAAAAAElFTkSuQmCC',
'options': [
{
'name': 'enabled',
'type': 'enabler',
},
{
'name': 'extra_score',
'advanced': True,
'label': 'Extra Score',
'type': 'int',
'default': 0,
'description': 'Starting score for each release found via this provider.',
}
],
},
 
Status
Not open for further replies.
Top