Add Yify Torrent Provider

This commit is contained in:
Aaron Florey
2013-06-23 00:11:01 +10:00
parent 9d495a10ec
commit 7e1bdc99eb
2 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
from main import Yify
def start():
return Yify()
config = [{
'name': 'yify',
'groups': [
{
'tab': 'searcher',
'subtab': 'providers',
'list': 'torrent_providers',
'name': 'Yify',
'description': 'Small HD movies, encoded by Yify.',
'wizard': False,
'options': [
{
'name': 'enabled',
'type': 'enabler',
'default': True
},
{
'name': 'extra_score',
'advanced': True,
'label': 'Extra Score',
'type': 'int',
'default': 0,
'description': 'Starting score for each release found via this provider.',
}
],
}
]
}]

View File

@@ -0,0 +1,46 @@
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
from couchpotato.core.helpers.variable import tryInt, cleanHost
from couchpotato.core.logger import CPLog
from couchpotato.core.providers.torrent.base import TorrentProvider
from couchpotato.environment import Env
import re
import time
import traceback
from pprint import pprint
log = CPLog(__name__)
class Yify(TorrentProvider):
urls = {
'test' : 'https://yify-torrents.com/api',
'search' : 'https://yify-torrents.com/api/list.json?keywords=%s&quality=%s',
'detail': 'https://yify-torrents.com/api/movie.json?id=%s'
}
http_time_between_calls = 1 #seconds
def _search(self, movie, quality, results):
try:
data = self.getJsonData(self.urls['search'] % (movie['library']['title'], quality['identifier']))
except:
log.error('Search on Yify (%s) failed (could not decode JSON)', params)
return
if data:
try:
for result in data:
results.append({
'id': result['MovieID'],
'name': result['MovieTitle'],
'url': result['TorrentUrl'],
'detail_url': self.urls['detail'] % result['MovieID'],
'size': self.parseSize(result['Size']),
'seeders': tryInt(result['TorrentSeeds']),
'leechers': tryInt(result['TorrentPeers'])
})
except:
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))