forked from zoexmh99/wvd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
site_coupang.py
47 lines (39 loc) · 2.46 KB
/
site_coupang.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
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
class SiteCoupang(SiteBase):
name = 'coupang'
name_on_filename = 'CP'
url_regex = request_url_regex = re.compile(r'coupangplay\.com\/play\/(?P<code>.*)\/(movie|episode)')
def __init__(self, db_id, json_filepath):
super(SiteCoupang, self).__init__(db_id, json_filepath)
def prepare(self):
try:
if self.db_item.url.find('MOVIE') != -1:
self.meta['content_type'] = 'movie'
elif self.db_item.url.find('TVSHOW') != -1:
self.meta['content_type'] = 'show'
for item in self.data['har']['log']['entries']:
if item['request']['method'] == 'GET' and item['request']['url'].find(f'discover/titles/{self.code}?') != -1:
self.meta['source'] = self.get_response(item).json()
Utility.write_json(os.path.join(self.temp_dir, f'{self.code}.meta.json'), self.meta['source'])
self.meta['title'] = self.meta['source']['data']['title']
if self.meta['source']['data']['as'] == 'MOVIE':
break
elif item['request']['method'] == 'GET' and item['request']['url'].find(f'discover/titles/') != -1:
self.meta['title'] = self.get_response(item).json()['data']['title']
break
if self.meta['source']['data']['as'] == 'EPISODE':
self.meta['content_type'] = 'show'
self.meta['season_number'] = self.meta['source']['data']['season']
self.meta['episode_number'] = self.meta['source']['data']['episode']
log = f"제목: [{self.meta['title']}] 시즌:[{self.meta['season_number']}], 에피:[{self.meta['episode_number']}]"
elif self.meta['source']['data']['as'] == 'MOVIE':
self.meta['content_type'] = 'movie'
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())
lic_url = 'https://www.coupangplay.com/api/playback/license'