Repository navigation
Expand file tree
/
Copy pathsource_mbc.py
More file actions
executable file
·76 lines (67 loc) · 2.19 KB
/
Copy pathsource_mbc.py
File metadata and controls
executable file
·76 lines (67 loc) · 2.19 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8 -*-
#########################################################
# python
import os
import sys
import logging
import traceback
import json
import re
import urllib
import requests
import threading
# third-party
# sjva 공용
# 패키지
from .plugin import logger, package_name
from .model import ModelSetting, ModelChannel
from source_base import SourceBase
#########################################################
class SourceMBC(SourceBase):
ch_list = [
'1|무한도전24|http://vodmall.imbc.com/util/player/onairurlutil_mudo.ashx?type=m|Y',
'2|MBC 표준FM|sfm|N',
'3|MBC FM4U|mfm|N',
'4|MBC 올댓뮤직|chm|N',
]
@classmethod
def get_channel_list(cls):
try:
ret = []
for item in SourceMBC.ch_list:
tmp = item.split('|')
c = ModelChannel(cls.source_name, tmp[0], tmp[1], None, True if tmp[3]=='Y' else False)
ret.append(c)
return ret
except Exception as e:
logger.error('Exception:%s', e)
logger.error(traceback.format_exc())
return ret
@classmethod
def get_url(cls, source_id, quality, mode):
try:
for item in SourceMBC.ch_list:
tmp = item.split('|')
if tmp[0] == source_id:
if tmp[3] == 'Y':
url = tmp[2]
else:
url = 'http://miniplay.imbc.com/AACLiveURL.ashx?protocol=M3U8&channel=%s&agent=android&androidVersion=24' % tmp[2]
break
url = requests.get(url).content.strip()
if mode == 'web_play':
return 'return_after_read', url
return 'redirect', url
except Exception as e:
logger.error('Exception:%s', e)
logger.error(traceback.format_exc())
return
@classmethod
def get_return_data(cls, source_id, url, mode):
try:
data = requests.get(url).content
return cls.change_redirect_data(data)
except Exception as e:
logger.error('Exception:%s', e)
logger.error(traceback.format_exc())
return data