def do_login(id, pw, json_return=False): try: body = { "type": "general", "id": id, "pushid": "", "password": pw, "profile": "0", "networktype": "", "carrier": "", "mcc": "", "mnc": "", "markettype": "unknown", "adid": "", "simoperator": "", "installerpackagename": "" } url = "%s/login?%s" % (config['base_url'], py_urllib.urlencode(config['base_parameter'])) response = session.post(url, json=body, headers=config['headers']) data = response.json() if 'credential' in data: if json_return: return data else: return data['credential'] else: logger.debug('login fail!!') if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc()) return
def vod_allprograms(page=1, limit=20, contenttype='program', genre='all', subgenre=None, orderby='new', is_cf=False): try: page = int(page) if type(page) != int else page param = get_baseparameter() param['genre'] = genre param['contenttype'] = contenttype param['type'] = 'all' param['weekday'] = 'all' param['offset'] = (page-1)*limit param['limit'] = limit param['orderby'] = orderby # 최신순 = new 과거순 = old if subgenre is not None: param['subgenre'] = subgenre if is_cf: url = "%s/cf/vod/allprograms?%s" % (config['base_url'], py_urllib.urlencode(param)) else: url = "%s/vod/allprograms?%s" % (config['base_url'], py_urllib.urlencode(param)) response = session.get(url, headers=config['headers']) data = response.json() #logger.debug(url) if response.status_code == 200: return data else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def movie_contents_detail(movie_id): """영화 상세 정보""" #https://apis.pooq.co.kr/cf/movie/contents/MV_CA01_DY0000011394?apikey=E5F3E0D30947AA5440556471321BB6D9 try: param = get_baseparameter() url = "%s/movie/contents/%s?%s" % (config['base_url'], movie_id, py_urllib.urlencode(param)) response = session.get(url, headers=config['headers']) data = response.json() if response.status_code == 200: return data else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def search_movie(keyword): try: url = 'https://apis.wavve.com/cf/search/list.js?keyword=%s&limit=20&offset=0&orderby=score&type=movie' % (py_urllib.quote(str(keyword))) response = session.get(url, headers=config['headers']) data = response.json() #logger.debug(url) if response.status_code == 200: if 'celllist' in data['cell_toplist']: return data['cell_toplist']['celllist'] else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc()) return search2(keyword, 'all')
def vod_contents_contentid(contentid): try: param = get_baseparameter() #param['ishevc'] = 'all' url = "%s/vod/contents/%s?%s" % (config['base_url'], contentid, py_urllib.urlencode(param)) response = session.get(url, headers=config['headers']) #logger.debug(url) data = response.json() #logger.debug(data) if response.status_code == 200: return data else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def vod_program_contents_programid(programid, page=1, limit=20): try: page = int(page) if type(page) != int else page param = get_baseparameter() param['offset'] = (page-1)*limit param['limit'] = limit param['orderby'] = 'new' url = "%s/vod/programs-contents/%s?%s" % (config['base_url'], programid, py_urllib.urlencode(param)) #logger.debug(url) response = session.get(url, headers=config['headers']) data = response.json() if response.status_code == 200: return data else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def search2(keyword, type_name): #return search(keyword, search_type='vodkeywordlist') try: #param = get_baseparameter() #param['keyword'] = keyword url = 'https://apis.wavve.com/cf/search/band.js?type=%s&keyword=%s&offset=0&limit=20&orderby=score&isplayymovie=y&apikey=E5F3E0D30947AA5440556471321BB6D9&&device=pc&drm=wm&partner=pooq&pooqzone=none®ion=kor&targetage=all' % (type_name, py_urllib.quote(str(keyword))) response = session.get(url, headers=config['headers']) data = response.json() #logger.debug(url) if response.status_code == 200: if 'celllist' in data['band']: return data['band']['celllist'] else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def search(keyword, search_type='all'): try: param = get_baseparameter() param['keyword'] = keyword url = "https://apis.wavve.com/search/instance/keywords?%s" % (py_urllib.urlencode(param)) response = session.get(url, headers=config['headers']) data = response.json() logger.debug(url) if response.status_code == 200: if search_type == 'all': return data else: for item in data: if item['type'] == search_type: return item else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def live_all_channels(genre='all'): try: param = get_baseparameter() param['genre'] = genre param['type'] = 'all' param['offset'] = 0 param['limit'] = 999 url = "%s/live/all-channels?%s" % (config['base_url'], py_urllib.urlencode(param)) response = session.get(url, headers=config['headers']) data = response.json() #logger.debug(url) #logger.debug(data) if response.status_code == 200: return data else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def vod_newcontents(page=1, limit=20, genre='all'): try: page = int(page) if type(page) != int else page param = get_baseparameter() param['genre'] = 'all' param['channel'] = 'all' param['type'] = 'all' param['weekday'] = 'all' param['offset'] = (page-1)*limit param['limit'] = limit param['orderby'] = 'new' # 최신순 = new 과거순 = old url = "%s/vod/newcontents?%s" % (config['base_url'], py_urllib.urlencode(param)) response = session.get(url, headers=config['headers']) data = response.json() #logger.debug(url) if response.status_code == 200: return data else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def live_epgs_channels(channel_id, startdatetime, enddatetime): try: param = get_baseparameter() param['genre'] = 'all' param['type'] = 'all' param['offset'] = 0 param['limit'] = 999 param['startdatetime'] = startdatetime param['enddatetime'] = enddatetime param['orderby'] = 'old' url = "%s/live/epgs/channels/%s?%s" % (config['base_url'], channel_id, py_urllib.urlencode(param)) #logger.debug(url) response = session.get(url, headers=config['headers']) data = response.json() if response.status_code == 200: return data else: if 'resultcode' in data: logger.debug(data['resultmessage']) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())
def streaming(contenttype, contentid, quality, action='hls', ishevc='y', isabr='y', return_url=False): """재생관련 정보 (스트리밍 / 다운로드 url 발급)""" # contenttype : live, vod, movie, clip, timemachine, onairvod # contentid : live = channelid, 프로그램 = programid, vod = contentid, 영화 = movieid, 클립 = clipid # action : hls, dash, progressive, download # quality : 100p (라디오), 360p, 480p, 720p, 1080p, 2160p, default, radio # authtype : signed url = url, http header 인증 = cookie # isabr - adaptive streaming 여부 : y, n # ishevc - hevc 여부 : y, n if quality == 'FHD': quality = '1080p' elif quality == 'HD': quality = '720p' elif quality == 'SD': quality = '480p' elif quality == 'UHD': quality = '2160p' #quality = '2160p' if contenttype == 'live': ishevc = 'n' isabr = 'n' try: param = get_baseparameter() param['credential'] = SystemModelSetting.get('site_wavve_credential') if contenttype == 'general': contenttype = 'vod' elif contenttype == 'onair': contenttype = 'onairvod' param['contenttype'] = contenttype param['contentid'] = contentid param['action'] = action param['quality'] = quality #param['guid'] = get_guid() param['guid'] = '' param['deviceModelId'] = 'Windows 10' param['authtype'] = 'url' #cookie, url #if contenttype == 'vod': # isabr = 'y' param['isabr'] = isabr param['ishevc'] = ishevc param['lastplayid'] = 'none' url = "%s/streaming?%s" % (config['base_url'], py_urllib.urlencode(param)) if return_url: logger.debug(url) return url response = session.get(url, headers=config['headers'], proxies=get_proxies()) data = response.json() if response.status_code == 200: #logger.debug(url) #logger.debug(data) try: if data['playurl'].startswith('https://event.pca.wavve.com'): logger.debug( 'playurl startswith https://event.pca.wavve.com!!!!!') return streaming_imsi(contenttype, contentid, quality, action=action, ishevc=ishevc, isabr=isabr) except: logger.debug('https://event.pca.wavve.com error') return data else: if 'resultcode' in data: #logger.debug(data['resultmessage']) pass except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc())