forked from atsushi444/iptv-epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBase.py
65 lines (44 loc) · 1.46 KB
/
Base.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
60
61
62
63
64
65
#coding=utf-8
import urllib2,json,tools
'''
<?xml version="1.0" encoding="UTF-8"?>
<tv generator-info-name="Generated by EPGGUIDE. Visit http://epgguide.net for more information." generator-info-url="http://epgguide.net">
<channel id="cctv1.cn">
<display-name lang="zh">CCTV 1 CN</display-name>
</channel>
<programme start="20180222044300 +0000" stop="20180222071500 +0000" channel="cctv1.cn">
<title lang="zh">星光大道2018-9 星光大道嘉年华(130分钟)</title>
</programme>
</tv>
'''
'''
{ 'tv':{
{'channel':{
'dispaly-name':
}
}
}
}
'''
####API网址
Interface="http://api.cntv.cn/epg/epginfo"
################base#####################
#向interface提交参数过去节目列表 json格式
def createJsonWithTVname(name,date):
file=urllib2.urlopen(Interface+"?"+"c="+name+"&serviceId=channel&d="+tools.timetofomat(date)+"&t=json")
###json 格式
parser = json.load(file,encoding="utf-8")
return parser[name]
###从tv节目列表中获取节目列表--->list
def getProgramsWithTV(tvParser):
islive=""
programs=tvParser['program']
return islive,programs
###从节目列表获取节目开始结束时间---->str ,start,stop
def getDateWithElement(ele,d):
start=ele['showTime']
duration=ele["duration"]
return tools.startime(start,d),tools.stoptime(start,duration,d)
def getNameOfprograms(ele):
name=ele['t'].encode("utf-8")
return name