Example #1
0
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())
Example #2
0
def getpermissionforcontent(contentid, contenttype='movie'):
    try:
        param = get_baseparameter()
        param['contentid'] = contentid
        param['contenttype'] = contenttype
        param['credential'] = SystemModelSetting.get('site_wavve_credential')

        url = "%s/getpermissionforcontent?%s" % (config['base_url'],
                                                 py_urllib.urlencode(param))
        response = session.get(url, headers=config['headers'])
        data = response.json()
        return data
    except Exception as exception:
        logger.error('Exception:%s', exception)
        logger.error(traceback.format_exc())
Example #3
0
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())
Example #4
0
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())
Example #5
0
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())
Example #6
0
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())    
Example #7
0
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())
Example #8
0
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())
Example #9
0
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())
Example #10
0
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())
Example #11
0
def streaming2(contenttype,
               contentid,
               quality,
               action='dash',
               ishevc='n',
               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))
        #logger.debug("STREAM2 : %s", url)
        if return_url:
            return url
        response = session.get(url,
                               headers=config['headers'],
                               proxies=get_proxies())
        data = response.json()

        #logger.debug(json.dumps(data, indent=4))
        if response.status_code == 200:
            #if data['playurl'].endswith('.mpd'):
            if data['playurl'].find('.mpd') != -1:
                if data['playurl'].endswith('.mpd'):
                    data['playurl'] += '?' + data['awscookie']
                ret = {}
                ret['uri'] = data['playurl']
                ret['drm_scheme'] = 'widevine'
                ret['drm_license_uri'] = data['drm']['drmhost']
                ret['drm_key_request_properties'] = {
                    'origin': 'https://www.wavve.com',
                    'sec-fetch-site': 'same-site',
                    'sec-fetch-mode': 'cors',
                    'user-agent':
                    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
                    #'Host' : 'cj.drmkeyserver.com',
                    'referer': 'https://www.wavve.com',
                    'pallycon-customdata': data['drm']['customdata'],
                    'cookie': data['awscookie'],
                    'content-type': 'application/octet-stream',
                }
                data['playurl'] = ret

            else:
                return streaming(contenttype, contentid, quality, ishevc='n')
            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())