-
Notifications
You must be signed in to change notification settings - Fork 30
/
site_wavve.py
59 lines (48 loc) · 2.63 KB
/
site_wavve.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
55
56
57
58
59
import os, sys, traceback, re, json, threading, time, shutil, subprocess, psutil, requests
from datetime import datetime
from .site_base import SiteBase, d, logger, package_name, ModelSetting, Utility, P, path_data, ToolBaseFile, webdriver, WebDriverWait, EC, By, Keys
from pywidevine.cdm import cdm, deviceconfig
from base64 import b64encode, b64decode
from pywidevine.decrypt.wvdecryptcustom import WvDecrypt
class SiteWavve(SiteBase):
name = 'wavve'
name_on_filename = 'WV'
url_regex = request_url_regex = re.compile(r'wavve\.com\/player\/(movie\?movieid=|vod\?contentid=|vod\?programid=.*?&contentid=)(?P<code>.*?)($|&)')
def __init__(self, db_id, json_filepath):
super(SiteWavve, self).__init__(db_id, json_filepath)
def prepare(self):
try:
for item in self.data['har']['log']['entries']:
if item['request']['method'] == 'GET' and item['request']['url'].find(f'contents/{self.code}?') != -1:
res = self.get_response(item)
self.meta['source'] = res.json()
Utility.write_json(os.path.join(self.temp_dir, f'{self.code}.meta.json'), self.meta['source'])
break
if 'programid' in self.meta['source']:
self.meta['content_type'] = 'show'
self.meta['title'] = self.meta['source']['programtitle']
self.meta['episode_number'] = int(self.meta['source']['episodenumber'])
self.meta['season_number'] = int(self.meta['source']['seasontitle'].split('시즌')[-1])
log = f"제목: [{self.meta['title']}] 시즌:[{self.meta['season_number']}], 에피:[{self.meta['episode_number']}]"
else:
self.meta['content_type'] = 'movie'
self.meta['title'] = self.meta['source']['title']
log = f"제목: [{self.meta['title']}]"
logger.debug(log)
self.add_log(log)
except Exception as e:
P.logger.error('Exception:%s', e)
P.logger.error(traceback.format_exc())
@classmethod
def do_driver_action(cls, ins):
try:
tag = WebDriverWait(ins.driver, 30).until(
EC.element_to_be_clickable((By.XPATH, '//button[@class="btn-play btn-default font-out"]'))
)
time.sleep(1)
tag.click()
ins.stop_timestamp = time.time()
except Exception as e:
P.logger.error(f'Exception:{str(e)}')
P.logger.error(traceback.format_exc())
lic_url = 'https://license.wavve.com/ri/licenseManager.do'