request template page... (2022.2.9) 1
This commit is contained in:
@@ -11,6 +11,7 @@ from datetime import datetime
|
|||||||
import copy
|
import copy
|
||||||
# third-party
|
# third-party
|
||||||
import requests
|
import requests
|
||||||
|
from lxml import html
|
||||||
# third-party
|
# third-party
|
||||||
from flask import request, render_template, jsonify
|
from flask import request, render_template, jsonify
|
||||||
from sqlalchemy import or_, and_, func, not_, desc
|
from sqlalchemy import or_, and_, func, not_, desc
|
||||||
@@ -50,6 +51,16 @@ class LogicOhli24(LogicModuleBase):
|
|||||||
'ohli24_image_url_prefix_episode': 'https://www.jetcloud-list.cc/thumbnail/',
|
'ohli24_image_url_prefix_episode': 'https://www.jetcloud-list.cc/thumbnail/',
|
||||||
}
|
}
|
||||||
current_headers = None
|
current_headers = None
|
||||||
|
current_data = None
|
||||||
|
session = requests.Session()
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
|
||||||
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
|
||||||
|
'Accept-Language': 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||||
|
'Referer': ''
|
||||||
|
}
|
||||||
|
useragent = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, '
|
||||||
|
'like Gecko) Chrome/96.0.4664.110 Whale/3.12.129.46 Safari/537.36'}
|
||||||
|
|
||||||
def __init__(self, P):
|
def __init__(self, P):
|
||||||
super(LogicOhli24, self).__init__(P, 'setting', scheduler_desc='ani365 자동 다운로드')
|
super(LogicOhli24, self).__init__(P, 'setting', scheduler_desc='ani365 자동 다운로드')
|
||||||
@@ -90,8 +101,8 @@ class LogicOhli24(LogicModuleBase):
|
|||||||
# code = req.form['code']
|
# code = req.form['code']
|
||||||
code = request.form['code']
|
code = request.form['code']
|
||||||
data = []
|
data = []
|
||||||
print(code)
|
# print(code)
|
||||||
logger.info("code::: %s", code)
|
# logger.info("code::: %s", code)
|
||||||
P.ModelSetting.set('ohli24_current_code', code)
|
P.ModelSetting.set('ohli24_current_code', code)
|
||||||
data = self.get_series_info(code)
|
data = self.get_series_info(code)
|
||||||
self.current_data = data
|
self.current_data = data
|
||||||
@@ -106,6 +117,66 @@ class LogicOhli24(LogicModuleBase):
|
|||||||
P.logger.error('Exception:%s', e)
|
P.logger.error('Exception:%s', e)
|
||||||
P.logger.error(traceback.format_exc())
|
P.logger.error(traceback.format_exc())
|
||||||
|
|
||||||
|
def get_series_info(self, code):
|
||||||
|
try:
|
||||||
|
if self.current_data is not None and 'code' in self.current_data and self.current_data['code'] == code:
|
||||||
|
return self.current_data
|
||||||
|
|
||||||
|
if code.startswith('http'):
|
||||||
|
code = code.split('c/')[1]
|
||||||
|
logger.info(f'code:::: {code}')
|
||||||
|
|
||||||
|
url = P.ModelSetting.get('ohli24_url') + '/c/' + code
|
||||||
|
# self.current_headers = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
|
||||||
|
# AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/96.0.4664.110 Whale/3.12.129.46 Safari/537.36',
|
||||||
|
# 'Referer': url }
|
||||||
|
|
||||||
|
response_data = LogicOhli24.get_html(url, timeout=10)
|
||||||
|
tree = html.fromstring(response_data)
|
||||||
|
title = tree.xpath('//div[@class="view-title"]/h1/text()')[0]
|
||||||
|
# image = tree.xpath('//div[@class="view-info"]/div[@class="image"]/div/img')[0]['src']
|
||||||
|
image = tree.xpath('//div[@class="image"]/div/img/@src')[0]
|
||||||
|
des_items = tree.xpath('//div[@class="list"]/p')
|
||||||
|
des = {}
|
||||||
|
des_key = ['_otit', '_dir', '_pub', '_tag', '_classifi', '_country', '_grade']
|
||||||
|
|
||||||
|
logger.info('des_items length:: %s', len(des_items))
|
||||||
|
for idx, item in enumerate(des_items):
|
||||||
|
key = des_key[idx]
|
||||||
|
span = item.xpath('.//span//text()')
|
||||||
|
logger.info(span)
|
||||||
|
des[key] = item.xpath('.//span/text()')[1]
|
||||||
|
|
||||||
|
logger.info(f'des::>> {des}')
|
||||||
|
image = image.replace('..', P.ModelSetting.get('ohli24_url'))
|
||||||
|
logger.info('images:: %s', image)
|
||||||
|
logger.info('title:: %s', title)
|
||||||
|
|
||||||
|
ser_description = tree.xpath('//div[@class="view-stocon"]/div[@class="c"]/text()')
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'title': title,
|
||||||
|
'image': image,
|
||||||
|
'date': '2022.01.11 00:30 (화)',
|
||||||
|
'ser_description': ser_description,
|
||||||
|
'des': des,
|
||||||
|
'episode': [
|
||||||
|
{
|
||||||
|
'title': '녹을 먹는 비스코 5화',
|
||||||
|
'thumbnail': 'https://ohli24.net/data/editor/2201/6ced5f453ef2fe9efb7edfa0e9e12d19_1641871470_4041.jpg',
|
||||||
|
'date': '2022-02-08'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
# logger.info(response_text)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
P.logger.error('Exception:%s', e)
|
||||||
|
P.logger.error(traceback.format_exc())
|
||||||
|
return {'ret': 'exception', 'log': str(e)}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def plugin_load():
|
def plugin_load():
|
||||||
try:
|
try:
|
||||||
@@ -133,6 +204,21 @@ class LogicOhli24(LogicModuleBase):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_html(url, referer=None, stream=False, timeout=5):
|
||||||
|
try:
|
||||||
|
if LogicOhli24.session is None:
|
||||||
|
LogicOhli24.session = requests.session()
|
||||||
|
|
||||||
|
# logger.debug('get_html :%s', url)
|
||||||
|
headers['Referer'] = '' if referer is None else referer
|
||||||
|
page_content = LogicOhli24.session.get(url, headers=headers, timeout=timeout)
|
||||||
|
data = page_content.text
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('Exception:%s', e)
|
||||||
|
logger.error(traceback.format_exc())
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
class Ohli24QueueEntity(FfmpegQueueEntity):
|
class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||||
def __init__(self, P, module_logic, info):
|
def __init__(self, P, module_logic, info):
|
||||||
@@ -140,7 +226,8 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
|||||||
self.vtt = None
|
self.vtt = None
|
||||||
self.season = 1
|
self.season = 1
|
||||||
self.content_title = None
|
self.content_title = None
|
||||||
self.make_episode_info()
|
# Todo::: 임시주석처리
|
||||||
|
# self.make_episode_info()
|
||||||
|
|
||||||
# episode info
|
# episode info
|
||||||
def make_episode_info(self):
|
def make_episode_info(self):
|
||||||
|
|||||||
@@ -16,10 +16,12 @@
|
|||||||
const ohli24_url = "{{arg['ohli24_url']}}";
|
const ohli24_url = "{{arg['ohli24_url']}}";
|
||||||
const current_data = null;
|
const current_data = null;
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
if ( "{{arg['ohli24_current_code']}}" !== "" ) {
|
if ( "{{arg['ohli24_current_code']}}" !== "" ) {
|
||||||
document.getElementById("code").value = "{{arg['ohli24_current_code']}}";
|
document.getElementById("code").value = "{{arg['ohli24_current_code']}}";
|
||||||
document.getElementById("analysis_btn").click();
|
// 값이 공백이 아니면 분석 버튼 계속 누름
|
||||||
|
{#document.getElementById("analysis_btn").click();#}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 분석 버튼 클릭시 호출
|
// 분석 버튼 클릭시 호출
|
||||||
@@ -35,18 +37,87 @@
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (ret) {
|
success: function (ret) {
|
||||||
if (ret.ret === 'success' && ret.data != null) {
|
if (ret.ret === 'success' && ret.data != null) {
|
||||||
console.log(ret.code)
|
{#console.log(ret.code)#}
|
||||||
{#make_program(ret.data)#}
|
console.log(ret.data)
|
||||||
|
make_program(ret.data)
|
||||||
} else {
|
} else {
|
||||||
$.notify('<strong>분석 실패</strong><br>' + ret.log, {type: 'warning'});
|
$.notify('<strong>분석 실패</strong><br>' + ret.log, {type: 'warning'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function make_program(data) {
|
||||||
|
const current_data = data;
|
||||||
|
str = '';
|
||||||
|
tmp = '<div class="form-inline">'
|
||||||
|
tmp += m_button('check_download_btn', '선택 다운로드 추가', []);
|
||||||
|
tmp += m_button('all_check_on_btn', '전체 선택', []);
|
||||||
|
tmp += m_button('all_check_off_btn', '전체 해제', []);
|
||||||
|
/*
|
||||||
|
tmp += ' <input id="new_title" name="new_title" class="form-control form-control-sm" value="'+data.title+'">'
|
||||||
|
tmp += '</div>'
|
||||||
|
tmp += m_button('apply_new_title_btn', '저장폴더명, 파일명 제목 변경', []);
|
||||||
|
tmp += m_button('search_tvdb_btn', 'TVDB', []);
|
||||||
|
tmp = m_button_group(tmp)
|
||||||
|
*/
|
||||||
|
str += tmp
|
||||||
|
// program
|
||||||
|
str += m_hr_black();
|
||||||
|
str += m_row_start(0);
|
||||||
|
tmp = ''
|
||||||
|
if (data.image != null)
|
||||||
|
tmp = '<img src="' + data.image + '" class="img-fluid">';
|
||||||
|
str += m_col(3, tmp)
|
||||||
|
tmp = ''
|
||||||
|
tmp += m_row_start(2) + m_col(3, '제목', 'right') + m_col(9, data.title) + m_row_end();
|
||||||
|
tmp += m_row_start(2) + m_col(3, '원제', 'right') + m_col(9, data.des._otit) + m_row_end();
|
||||||
|
tmp += m_row_start(2) + m_col(3, '감독', 'right') + m_col(9, data.des._dir) + m_row_end();
|
||||||
|
tmp += m_row_start(2) + m_col(3, '제작사', 'right') + m_col(9, data.des._pub) + m_row_end();
|
||||||
|
{#tmp += m_row_start(2) + m_col(3, '장르', 'right') + m_col(9, data.des._tag.join(' | ')) + m_row_end();#}
|
||||||
|
tmp += m_row_start(2) + m_col(3, '장르', 'right') + m_col(9, data.des._tag) + m_row_end();
|
||||||
|
tmp += m_row_start(2) + m_col(3, '분류', 'right') + m_col(9, data.des._classifi) + m_row_end();
|
||||||
|
tmp += m_row_start(2) + m_col(3, '방영일', 'right') + m_col(9, data.date+'('+data.day+')') + m_row_end();
|
||||||
|
tmp += m_row_start(2) + m_col(3, '등급', 'right') + m_col(9, data.des._grade) + m_row_end();
|
||||||
|
tmp += m_row_start(2) + m_col(3, '줄거리', 'right') + m_col(9, data.ser_description) + m_row_end();
|
||||||
|
str += m_col(9, tmp)
|
||||||
|
str += m_row_end();
|
||||||
|
|
||||||
|
str += m_hr_black();
|
||||||
|
for (i in data.episode) {
|
||||||
|
str += m_row_start(); tmp = '';
|
||||||
|
if (data.episode[i].thumbnail)
|
||||||
|
tmp = '<img src="'+ data.episode[i].thumbnail + '" class="img-fluid">'
|
||||||
|
str += m_col(3, tmp)
|
||||||
|
tmp = '<strong>' + data.episode[i].title+ '</strong>';
|
||||||
|
tmp += '<br>';
|
||||||
|
tmp += data.episode[i].date + '<br>';
|
||||||
|
|
||||||
|
tmp += '<div class="form-inline">'
|
||||||
|
tmp += '<input id="checkbox_'+i+'" name="checkbox_'+i+'" type="checkbox" checked data-toggle="toggle" data-on="선 택" data-off="-" data-onstyle="success" data-offstyle="danger" data-size="small"> '
|
||||||
|
tmp += m_button('add_queue_btn', '다운로드 추가', [{'key':'idx', 'value':i}])
|
||||||
|
tmp += '</div>'
|
||||||
|
str += m_col(9, tmp)
|
||||||
|
str += m_row_end();
|
||||||
|
if (i != data.length -1) str += m_hr(0);
|
||||||
|
}
|
||||||
|
document.getElementById("episode_list").innerHTML = str;
|
||||||
|
$('input[id^="checkbox_"]').bootstrapToggle()
|
||||||
|
}
|
||||||
|
|
||||||
$("body").on('click', '#go_ohli24_btn', function(e){
|
$("body").on('click', '#go_ohli24_btn', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.open("{{arg['ohli24_url']}}", "_blank");
|
window.open("{{arg['ohli24_url']}}", "_blank");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("body").on('click', '#all_check_on_btn', function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
$('input[id^="checkbox_"]').bootstrapToggle('on')
|
||||||
|
});
|
||||||
|
|
||||||
|
$("body").on('click', '#all_check_off_btn', function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
$('input[id^="checkbox_"]').bootstrapToggle('off')
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user