-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
54 lines (43 loc) · 1.6 KB
/
client.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
#-*- coding: utf-8 -*-
__author__ = 'kovtash'
from AOSFetcher import AOSFetcher
from vpwebAPI import vpwebAPI
import sys
class CompleteCallback():
def __init__(self,showKey,episodeNumber):
self.showKey=showKey
self.episodeNumber=episodeNumber
def complete(self):
vpwebAPI().setEpisodeDownloaded(self.showKey,self.episodeNumber)
class Fetcher():
def __init__(self,serviceList):
self._serviceList=[]
for service in serviceList:
self._serviceList.append((service[0],service[1]()))
def fetchAll(self):
for service in self._serviceList:
service[1].downloadAll()
def fetchNewEpisodeList(self):
episodeList=vpwebAPI().newEpisodes
for service in self._serviceList:
shows=episodeList['services'][service[0]]
serviceWorker = service[1]
for show in shows:
showWorker = serviceWorker.appendShow(show['title'],show['season'],show['posterURL'])
for episode in show['episodes']:
print episode['url']
showWorker.appendEpisode(episode['number'],episode['url'],CompleteCallback(show['showKey'],episode['number']))
if __name__=='__main__':
try:
import socket
s = socket.socket()
host = socket.gethostname()
port = 35636 #make sure this port is not used on this system
s.bind((host, port))
except:
#pass
print "Already running. Exiting."
sys.exit(0)
test = Fetcher([('animeonline.su',AOSFetcher)])
test.fetchNewEpisodeList()
test.fetchAll()