-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (55 loc) · 2.31 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from pulsar import provider
import common
import re
# this read the settings
settings = common.Settings()
# define the browser
browser = common.Browser()
# create the filters
filters = common.Filtering()
# using function from Steeve to add Provider's name and search torrent
def extract_torrents(data):
try:
filters.information() # print filters settings
data = common.clean_html(data)
#lname = re.findall('.HorribleSubs.(.*?)<', data) # list the names
cont = 0
for name, magnet in re.findall('class="dl-label"><i>(.*?)</i>.*?a href="(magnet:.*?)"', data):
#name = lname[cm] + ' - ' + settings.name_provider
if filters.verify(name, None):
yield {"name": name, "uri": magnet} # return le torrent
cont += 1
else:
provider.log.warning(filters.reason)
if cont == settings.max_magnets: # limit magnets
break
provider.log.info('>>>>>>' + str(cont) + ' torrents sent to Pulsar<<<<<<<')
except:
provider.log.error('>>>>>>>ERROR parsing data<<<<<<<')
provider.notify(message='ERROR parsing data', header=None, time=5000, image=settings.icon)
def search(query):
query += ' ' + settings.extra # add the extra information
query = filters.type_filtering(query, '+') # check type filter and set-up filters.title
url_search = "%s/lib/search.php?value=%s" % (settings.url,query) # change in each provider
provider.log.info(url_search)
if browser.open(url_search):
results = extract_torrents(browser.content)
else:
provider.log.error('>>>>>>>%s<<<<<<<' % browser.status)
provider.notify(message=browser.status, header=None, time=5000, image=settings.icon)
results = []
return results
def search_movie(info):
return []
def search_episode(info):
if info['absolute_number'] == 0:
query = info['title'].encode('utf-8') + ' s%02de%02d' % (info['season'], info['episode']) # define query
else:
query = info['title'].encode('utf-8') + ' %02d' % info['absolute_number'] # define query anime
query += ' #TV&FILTER' #to use TV filters
return search(query)
# This registers your module for use
provider.register(search, search_movie, search_episode)
del settings
del browser
del filters