-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpwebAPI.py
46 lines (37 loc) · 1.33 KB
/
vpwebAPI.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
#-*- coding: utf-8 -*-
__author__ = 'kovtash'
import os.path,downloader,logging
class vpwebAPI():
def __init__(self):
self._serverURL='http://vpsrvr.appspot.com'
self._newEpisodes=None
def getData(self,dataURL):
requestURL=os.path.join(self._serverURL,dataURL)
result=None
response=downloader.JSONDocGet(requestURL).data
if response is not None:
try:
result=response['response']
except KeyError:
pass
return result
@property
def newEpisodes(self):
if self._newEpisodes is None:
self._newEpisodes=self.getData('getnewepisodes')
return self._newEpisodes
def getServiceShows(self,serviceName):
try:
result=self.newEpisodes['services'][serviceName]
except KeyError:
result=None
return result
def setEpisodeDownloaded(self,showKey,episodeNumber):
#TODO:setEpisodeDownloaded
requestURL=os.path.join(self._serverURL,'setdownloaded')
logging.error("".join([episodeNumber]))
downloader.DocGet(requestURL,params=[("ep_num",episodeNumber),("show_key",showKey)])
if __name__=='__main__':
testModel=vpwebAPI()
logging.error(testModel.newEpisodes)
logging.error(testModel.getServiceShows('animeonline.su'))