Skip to content

Commit

Permalink
update magnet url
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoxia committed May 13, 2015
1 parent 99c2872 commit 0127a5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 0 additions & 4 deletions supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,4 @@ environment=PATH="/home/job/env/bin"
directory=/home/job/ssbc
command=gunicorn -k gevent -b :8002 -w 2 ssbc.wsgi

[program:mongod]
user=job
command=/home/job/bin/mongod --storageEngine=wiredTiger --dbpath=/data/mongodb


4 changes: 2 additions & 2 deletions web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def hash(request, h):
if 'files' in d['info']:
d['info']['files'] = [y for y in d['info']['files'] if not y['path'].startswith(u'_')]
d['info']['files'].sort(key=lambda x:x['length'], reverse=True)
d['magnet_url'] = 'magnet:?' + urllib.urlencode({'xt':'urn:btih:%s'% (d['info']['info_hash']), 'dn':d['info']['name'].encode('utf8')})
d['magnet_url'] = 'magnet:?xt=urn:btih:' + d['info']['info_hash'] + '&' + urllib.urlencode({'dn':d['info']['name'].encode('utf8')})
d['download_url'] = 'http://www.so.com/s?' + urllib.urlencode({'ie':'utf-8', 'src': 'ssbc', 'q': d['info']['name'].encode('utf8')})
return render(request, 'info.html', d)

Expand Down Expand Up @@ -69,7 +69,7 @@ def search(request, keyword, p):

for x in d['result']['items']:
x.update(j[str(x['id'])])
x['magnet_url'] = 'magnet:?' + urllib.urlencode({'xt':'urn:btih:%s'% (x['info_hash']), 'dn':x['name'].encode('utf8')})
x['magnet_url'] = 'magnet:?xt=urn:btih:' + x['info_hash'] + '&' + urllib.urlencode({'dn':x['name'].encode('utf8')})
if 'files' in x:
x['files'] = [y for y in x['files'] if not y['path'].startswith(u'_')][:5]
x['files'].sort(key=lambda x:x['length'], reverse=True)
Expand Down

0 comments on commit 0127a5f

Please sign in to comment.