def post(self): parser = reqparse.RequestParser() parser.add_argument('station') parser.add_argument('start_at') parser.add_argument('end_at') args = parser.parse_args() station = args['station'] start_at = args['start_at'] end_at = args['end_at'] file_name = 'Radiko.{}.{}.{}.raw.aac'.format(station, start_at, end_at) data = Radio.getData(file_name) if data: return handler(0, "{}".format(station), entities=data) else: file_name = 'Radiko.{}.{}.{}.raw.aac'.format( station, start_at, end_at) data = radiko.get(file_name, station, start_at, end_at) if data: radiko.get(file_name, station, start_at, end_at) Radio.update(file_name, data) return handler(0, "{}".format(station), entities={ 'name': file_name, 'url': data }) else: return handler(1, "No Radio")
def get(self): utime = updateTimeGet("drama")["time"] if utime: utime_timestamp = int( time.mktime(time.strptime(utime, '%Y-%m-%d %H:%M:%S'))) ntime_timestamp = int(time.time()) ltime_timestamp = utime_timestamp + 14400 sec = ltime_timestamp - ntime_timestamp return handler(0, "Drama update time", second=sec, time=utime) else: return handler(1, "No data")
def post(self): parser = reqparse.RequestParser() parser.add_argument('username') parser.add_argument('password') args = parser.parse_args() username = args["username"] password = args["password"] if username and password is not None: token = User.login(username, password) if not token: return handler(1, "username or password invalid") else: return handler(1, "username or password invalid") return handler(0, "Hello " + username, token=token)
def get(self): clientip = request.remote_addr limitinfo = limitIP(clientip) if limitinfo: data = STchan.top15() if data: stutime = updateTimeGet("stchannel")["time"] stinfo = list(data) return handler(0, "STchannel video listing", time=stutime, entities=stinfo) else: return handler(1, "No listing") else: return handler(1, "Too many requests per second")
def post(self): parser = reqparse.RequestParser() parser.add_argument('username') args = parser.parse_args() username = args["username"] User.logout(username) return handler(0, "GoodBye " + username)
def get(self, subname): subnames = ["tvbt", "subpig", "fixsub"] if subname not in subnames: return handler(1, "The subtitle group does not exist") else: clientip = request.remote_addr limitinfo = limitIP(clientip) if limitinfo: data = Dramas.getData(subname) if data: dramaContent = data return handler(0, "{} drama listing".format(subname), name=subname, entities=dramaContent) else: return handler(1, "No drama data") else: return handler(1, "Too many requests per second")
def get(self): parser = reqparse.RequestParser() parser.add_argument('type', required=True, help="Type is required") parser.add_argument('page', help="Page code is required") para = parser.parse_args() mtype = int(para["type"]) page = para["page"] if mtype in range(4) or mtype == 100: type_info = Rika.getType(mtype) pages = Rika.getPages(mtype) if page: if mtype == 100: allinfo = Rika.getPageInfo(page) if allinfo: return handler(0, "All message", entities=allinfo, pages=pages) else: return handler(1, "No data") else: partinfo = Rika.getPageInfo(page, mtype) if partinfo: return handler(0, "{} message".format(type_info), entities=partinfo, pages=pages) else: return handler(1, "No data") else: return handler(1, "Type and Page is required") else: return handler(1, "No such type, only 0-3 or 100")
def get(self): parser = reqparse.RequestParser() parser.add_argument('kw', required=True, help="Keyword is required") parser.add_argument('ac', required=True, help="Region code is required") para = parser.parse_args() kw = para["kw"] ac = para["ac"] if kw and ac: clientip = request.remote_addr limitinfo = limitIP(clientip) if limitinfo: keyword = kw.encode("utf-8") data = Programs.getData(kw, ac) if data: tvdata = data["prog_info"] tvurl = data["yahoo_url"] return handler(0, "Program information", ori_url=tvurl, entities=tvdata, cache="HIT") else: y = jprogram.yahooTV() tvinfo = y.tvInfos(keyword, ac) if tvinfo: tvdata = tvinfo[0] tvurl = tvinfo[1] Programs.update(kw, ac, tvurl, tvdata) return handler(0, "Program information", ori_url=tvurl, entities=tvdata) else: return handler(1, "No information") else: return handler(1, "Too many requests per second") else: return handler(1, "Parameter error")
def post(self): parser = reqparse.RequestParser() parser.add_argument('username', required=True, help="username is required") parser.add_argument('password', required=True, help="password is required") parser.add_argument('flag') args = parser.parse_args() username = args["username"] password = args["password"] flag = args["flag"] if flag == secret_key: if username is None or password is None: return handler(1, "Username or Password Invalid") if User.register(username, password): return handler(0, "Dear " + username + " Welcome to API World!") else: return handler(1, "User already exists") else: return handler(1, "Permission denied")
def get(self, target): parser = reqparse.RequestParser() parser.add_argument('url', required=True, help="URL is required") para = parser.parse_args() url = para.get("url") targets = ["news", "hls", "twitter"] if target not in targets: return handler(1, "The type is not supported") else: clientip = request.remote_addr limitinfo = limitIP(clientip) if limitinfo: if target == "news": p = picdown.picdown() urldict = p.urlCheck(url) if urldict: sitename = urldict["type"] siteurl = urldict["data"] siteurl_check = siteurl.split("?") siteurl = siteurl_check[0] if len(siteurl_check) == 2: if siteurl_check[1] == "update": updateFlag = True else: updateFlag = False else: updateFlag = False data = Medias.getData(siteurl) if data and updateFlag is False: imgurls = data["source"] return handler( 0, "The news has a total of {} pictures".format( len(imgurls)), type=target, entities=imgurls, cache="HIT") elif updateFlag is True or data is None: if updateFlag: cache = "UPDATE" else: cache = "MISS" imgurls = p.picRouter(urldict) if imgurls: Medias.update(target, sitename, siteurl, imgurls) return handler( 0, "The news has a total of {} pictures". format(len(imgurls)), type=target, entities=imgurls, cache=cache) else: return handler(1, "This news has no pictures") else: return handler(1, "The news site is not supported") elif target == "hls": sr = srurl.HLSPlayList() urltype = sr.urlCheck(url) if urltype: site = urltype[0] hls_url = urltype[1] data = Medias.getLiveData(hls_url) if data: m3u8_url = data["source"] return handler( 0, "This is a {} playlist".format(site), type=target, entities=m3u8_url, cache="HIT") else: m3u8_url = sr.urlRouter(urltype) if m3u8_url: Medias.updateLive(target, site, hls_url, m3u8_url) return handler( 0, "This is a {} playlist".format(site), type=target, entities=m3u8_url) else: return handler(1, "No content") else: return handler(1, "The hls site is not supported") elif target == "twitter": url = url.split("?")[0] data = Medias.getData(url) if data: tweet_vurl = data["source"] return handler(0, "This is a Twitter Video url", type=target, entities=tweet_vurl, cache="HIT") else: site = "twitter.com" tweet_vurl = tweetV2.getVideoURL(url) if tweet_vurl: Medias.update(target, site, url, tweet_vurl) return handler(0, "This is a Twitter Video url", type=target, entities=tweet_vurl) else: return handler(1, "This url has no video") else: return handler(1, "Too many requests per second")