Skip to content

Commit

Permalink
Merge commit 'f038451c5c423d73f0281d92728be5c6fd456687' as 'script.ip…
Browse files Browse the repository at this point in the history
…tvtool'
  • Loading branch information
taxigps committed Jul 23, 2017
2 parents 857fa65 + f038451 commit 76c96e5
Show file tree
Hide file tree
Showing 75 changed files with 450 additions and 0 deletions.
28 changes: 28 additions & 0 deletions script.iptvtool/addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.iptvtool"
name="IPTV Tool" version="1.0.0" provider-name="Taxigps">
<requires>
<import addon="xbmc.python" version="2.1.0" />
<import addon="script.module.simplejson" version="2.0.10" />
</requires>

<extension point="xbmc.python.script" library="default.py">
<provides>executable</provides>
</extension>

<extension point="xbmc.service" library="epgservice.py" start="login" />

<extension point="xbmc.addon.metadata">
<summary lang="en">Automatic setting PVR IPTV Simple Client</summary>
<summary lang="zh">自动设置PVR的IPTV客户端</summary>
<description lang="en">Automatic setting PVR IPTV Simple Client for M3U playlist, channels logos and EPG</description>
<description lang="zh">自动设置PVR的IPTV客户端,包括M3U播放列表、频道图标和电子节目单</description>
<disclaimer lang="en"></disclaimer>
<language></language>
<platform>all</platform>
<license>GNU GENERAL PUBLIC LICENSE, Version 2</license>
<forum></forum>
<website></website>
<source>https://github.com/taxigps/script.iptvtool</source>
</extension>
</addon>
2 changes: 2 additions & 0 deletions script.iptvtool/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[B]1.0.0[/B]
- Initial version
35 changes: 35 additions & 0 deletions script.iptvtool/default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-

import xbmcgui
import xbmcaddon
import os

from resources.lib.utils import *

mode = xbmcgui.Dialog().select(getString(30030),[getString(30031),getString(30032)])

#check if program should be run
if(mode != -1):

if(mode == 0):
#open the settings dialog
openSettings()

elif(mode == 1):
addonid = 'pvr.iptvsimple'
iptvsimple = xbmcaddon.Addon(id=addonid)

iptvsimple.setSetting("logoPathType", "0") #set to local path
logoPath = os.path.join(addon_dir(), "resources", "media")
iptvsimple.setSetting("logoPath", logoPath)

iptvsimple.setSetting("m3uPathType", "0") #set to local path
m3uPath = os.path.join(addon_dir(), "resources", "channel.m3u")
iptvsimple.setSetting("m3uPath", m3uPath)

if getSetting("epg") == "true":
iptvsimple.setSetting("epgPathType", "0") #set to local path
epgPath = os.path.join(data_dir(), "epg.xml")
iptvsimple.setSetting("epgPath", epgPath)

iptvsimple.openSettings()
76 changes: 76 additions & 0 deletions script.iptvtool/epgservice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-

import xbmc
import os
import datetime
import traceback
import urllib2
import simplejson

from resources.lib.utils import *

def updateChannel(fHandle, channelID, channelName):
try:
log("Updating channel " + channelID)

dateInChina = (datetime.datetime.utcnow() + datetime.timedelta(hours=8)).replace(hour=0, minute=0) #UTC +0800

#Get data
request = urllib2.Request("http://api.cntv.cn/epg/epginfo?serviceId=tvcctv&c=%s&d=%s" % (channelID, dateInChina.strftime("%Y%m%d")))
request.add_header("Referer", "http://tv.cntv.cn/epg")
resp = urllib2.urlopen(request)
data = resp.read().decode("utf-8")
programmes = simplejson.loads(data)[channelID]['program']

#Write channel data
fHandle.write('<channel id="{0}">\n'.format(channelID))
fHandle.write('<display-name lang="cn">{0}</display-name>\n'.format(channelName))
fHandle.write('</channel>\n'.format(channelID))

#Write programme data
for entry in programmes:
startTime = datetime.datetime.fromtimestamp(entry['st'])
stopTime = datetime.datetime.fromtimestamp(entry['et'])

fHandle.write('<programme start="{0}" stop="{1}" channel="{2}">\n'.format(formatDate(startTime), formatDate(stopTime), channelID))
fHandle.write('<title lang="cn">{0}</title>\n'.format(entry['t'].encode("utf-8")))
fHandle.write('</programme>\n')
except Exception:
log(traceback.format_exc())

def formatDate(obj):
return obj.strftime("%Y%m%d%H%M00 +0800")

def doUpdate():
log("Updating EPG")

try:
epgfile = os.path.join(data_dir(), "epg.xml")
fHandle = open(epgfile, "w")
fHandle.write('<?xml version="1.0" encoding="utf-8" ?>\n')
fHandle.write('<tv>\n')

if getSetting("epg_cctv") == "true":
for id, name in CHANNEL_CCTV:
updateChannel(fHandle, id, name)

if getSetting("epg_province") == "true":
for id, name in CHANNEL_PROV:
updateChannel(fHandle, id, name)

fHandle.write('</tv>\n')
fHandle.close()

except Exception:
log(traceback.format_exc())

log("Finished updating EPG")

#Set a timer for the next update
startTimer(60)

def startTimer(delay): #minutes
xbmc.executebuiltin("AlarmClock({0},RunScript({1}),{2},True)".format("EPGUpdate", os.path.join(addon_dir(), "epgservice.py"), delay))

if getSetting("epg") == "true":
doUpdate()
Binary file added script.iptvtool/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions script.iptvtool/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
115 changes: 115 additions & 0 deletions script.iptvtool/resources/channel.m3u
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#EXTM3U
#EXTINF:-1 tvg-id="cctv1" tvg-logo="cctv1.png",CCTV-1HD
http://222.191.24.6:6610/2/2/ch00000090990000001021/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv5" tvg-logo="cctv5.png",CCTV-5HD
http://222.191.24.6:6610/2/2/ch00000090990000001240/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv5plus" tvg-logo="cctv5plus.png",CCTV-5+HD
http://222.191.24.6:6610/2/2/ch00000090990000001044/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="btv1" tvg-logo="btv1.png",北京卫视HD
http://122.96.52.11:8080/gitv_live/BTV-1/BTV-1.m3u8
#EXTINF:-1 tvg-id="hubei" tvg-logo="hubei.png",湖北卫视HD
http://223.82.250.95:8080/ysten-businessmobile/live/hdhubeistv/astv.m3u8
#EXTINF:-1 tvg-id="hunan" tvg-logo="hunan.png",湖南卫视HD
http://223.82.250.95:8080/ysten-businessmobile/live/hdhunanstv/astv.m3u8
#EXTINF:-1 tvg-id="shenzhen" tvg-logo="shenzhen.png",深圳卫视HD
http://223.82.250.95:8080/ysten-businessmobile/live/hdshenzhenstv/astv.m3u8
#EXTINF:-1 tvg-id="guangdong" tvg-logo="guangdong.png",广东卫视HD
http://223.82.250.95:8080/ysten-businessmobile/live/hdguangdongstv/astv.m3u8
#EXTINF:-1 tvg-id="tianjin" tvg-logo="tianjin.png",天津卫视HD
http://223.82.250.95:8080/ysten-businessmobile/live/hdtianjinstv/astv.m3u8
#EXTINF:-1 tvg-id="jiangxi" tvg-logo="jiangxi.png",江西卫视HD
http://223.82.250.95:8080/ysten-businessmobile/live/jiangxistv/astv.m3u8
#EXTINF:-1 tvg-id="jiangsu" tvg-logo="jiangsu.png",江苏卫视HD
http://222.191.24.6:6610/2/2/ch00000090990000001301/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="fenghuang" tvg-logo="fenghuang.png",凤凰中文HD
http://223.82.250.95:8080/ysten-businessmobile/live/fhchinese/dujuejiami.m3u8
#EXTINF:-1 tvg-id="fenghuang2" tvg-logo="fenghuang2.png",凤凰资讯HD
http://223.82.250.94:8080/ysten-businessmobile/live/fhzixun/dujuejiami.m3u8
#EXTINF:-1 tvg-id="cctv1" tvg-logo="cctv1.png",CCTV-1
http://222.191.24.6:6610/2/2/ch00000090990000001018/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv2" tvg-logo="cctv2.png",CCTV-2
http://222.191.24.6:6610/2/2/ch00000090990000001025/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv3" tvg-logo="cctv3.png",CCTV-3
http://222.191.24.6:6610/2/2/ch00000090990000001027/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv4" tvg-logo="cctv4.png",CCTV-4
http://222.191.24.6:6610/2/2/ch00000090990000001118/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv5" tvg-logo="cctv5.png",CCTV-5
http://222.191.24.6:6610/2/2/ch00000090990000001029/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv5plus" tvg-logo="cctv5plus.png",CCTV-5+
http://222.191.24.6:6610/2/2/ch00000090990000001297/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv6" tvg-logo="cctv6.png",CCTV-6
http://222.191.24.6:6610/2/2/ch00000090990000001031/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv7" tvg-logo="cctv7.png",CCTV-7
http://222.191.24.6:6610/2/2/ch00000090990000001120/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv8" tvg-logo="cctv8.png",CCTV-8
http://222.191.24.6:6610/2/2/ch00000090990000001033/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctvjilu" tvg-logo="cctvjilu.png",CCTV-9
http://222.191.24.6:6610/2/2/ch00000090990000001035/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv10" tvg-logo="cctv10.png",CCTV-10
http://222.191.24.6:6610/2/2/ch00000090990000001124/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv11" tvg-logo="cctv11.png",CCTV-11
http://222.191.24.6:6610/2/2/ch00000090990000001126/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv12" tvg-logo="cctv12.png",CCTV-12
http://222.191.24.6:6610/2/2/ch00000090990000001128/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv13" tvg-logo="cctv13.png",CCTV-13
http://222.191.24.6:6610/2/2/ch00000090990000001130/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctvchild" tvg-logo="cctvchild.png",CCTV-14少儿
http://222.191.24.6:6610/2/2/ch00000090990000001133/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="cctv15" tvg-logo="cctv15.png",CCTV-15音乐
http://222.191.24.6:6610/2/2/ch00000090990000001134/index.m3u8?ispcode=3
#EXTINF:-1 tvg-id="anhui" tvg-logo="anhui.png",安徽卫视
http://223.82.250.95:8080/ysten-businessmobile/live/anhuistv/astv.m3u8
#EXTINF:-1 tvg-id="chongqing" tvg-logo="chongqing.png",重庆卫视
http://122.96.52.11:8080/gitv_live/G_CHONGQING/G_CHONGQING.m3u8
#EXTINF:-1 tvg-id="dongfang" tvg-logo="dongfang.png",东方卫视
http://122.96.52.11:8080/gitv_live/G_DONGFANG/G_DONGFANG.m3u8
#EXTINF:-1 tvg-id="dongnan" tvg-logo="dongnan.png",东南卫视
http://122.96.52.11:8080/gitv_live/DNWS/DNWS.m3u8
#EXTINF:-1 tvg-id="gansu" tvg-logo="gansu.png",甘肃卫视
http://122.96.52.11:8080/gitv_live/G_GANSU/G_GANSU.m3u8
#EXTINF:-1 tvg-id="guangdong" tvg-logo="guangdong.png",广东卫视
http://122.96.52.11:8080/gitv_live/G_GUANGDONG/G_GUANGDONG.m3u8
#EXTINF:-1 tvg-id="guangxi" tvg-logo="guangxi.png",广西卫视
http://122.96.52.11:8080/gitv_live/GXWS/GXWS.m3u8
#EXTINF:-1 tvg-id="guizhou" tvg-logo="guizhou.png",贵州卫视
http://122.96.52.11:8080/gitv_live/G_GUIZHOU/G_GUIZHOU.m3u8
#EXTINF:-1 tvg-id="hebei" tvg-logo="hebei.png",河北卫视
http://223.82.250.95:8080/ysten-businessmobile/live/hebeistv/astv.m3u8
#EXTINF:-1 tvg-id="henan" tvg-logo="henan.png",河南卫视
http://122.96.52.11:8080/gitv_live/HENAN/HENAN.m3u8
#EXTINF:-1 tvg-id="hubei" tvg-logo="hubei.png",湖北卫视
http://122.96.52.11:8080/gitv_live/G_HUBEI/G_HUBEI.m3u8
#EXTINF:-1 tvg-id="hunan" tvg-logo="hunan.png",湖南卫视
http://122.96.52.11:8080/gitv_live/G_HUNAN/G_HUNAN.m3u8
#EXTINF:-1 tvg-id="jiangxi" tvg-logo="jiangxi.png",江西卫视
http://122.96.52.11:8080/gitv_live/JXWS/JXWS.m3u8
#EXTINF:-1 tvg-id="jilin" tvg-logo="jilin.png",吉林卫视
http://122.96.52.11:8080/gitv_live/G_JILIN/G_JILIN.m3u8
#EXTINF:-1 tvg-id="liaoning" tvg-logo="liaoning.png",辽宁卫视
http://223.82.250.95:8080/ysten-businessmobile/live/liaoningstv/astv.m3u8
#EXTINF:-1 tvg-id="neimenggu" tvg-logo="neimenggu.png",内蒙古卫视
http://122.96.52.11:8080/gitv_live/G_NEIMENGGU/G_NEIMENGGU.m3u8
#EXTINF:-1 tvg-id="ningxia" tvg-logo="ningxia.png",宁夏卫视
http://122.96.52.11:8080/gitv_live/G_NINGXIA/G_NINGXIA.m3u8
#EXTINF:-1 tvg-id="qinghai" tvg-logo="qinghai.png",青海卫视
http://122.96.52.11:8080/gitv_live/G_QINGHAI/G_QINGHAI.m3u8
#EXTINF:-1 tvg-id="shandong" tvg-logo="shandong.png",山东卫视
http://122.96.52.11:8080/gitv_live/SDWS/SDWS.m3u8
#EXTINF:-1 tvg-id="shan1xi" tvg-logo="shan1xi.png",山西卫视
http://122.96.52.11:8080/gitv_live/SXWS/SXWS.m3u8
#EXTINF:-1 tvg-id="shan3xi" tvg-logo="shan3xi.png",陕西卫视
http://223.82.250.95:8080/ysten-businessmobile/live/shanxi1stv/astv.m3u8
#EXTINF:-1 tvg-id="shenzhen" tvg-logo="shenzhen.png",深圳卫视
http://122.96.52.11:8080/gitv_live/G_SHENZHEN/G_SHENZHEN.m3u8
#EXTINF:-1 tvg-id="sichuan" tvg-logo="sichuan.png",四川卫视
http://122.96.52.11:8080/gitv_live/SCWS/SCWS.m3u8
#EXTINF:-1 tvg-id="tianjin" tvg-logo="tianjin.png",天津卫视
http://122.96.52.11:8080/gitv_live/TJWS/TJWS.m3u8
#EXTINF:-1 tvg-id="xinjiang" tvg-logo="xinjiang.png",新疆卫视
http://122.96.52.11:8080/gitv_live/G_XINJIANG/G_XINJIANG.m3u8
#EXTINF:-1 tvg-id="yunnan" tvg-logo="yunnan.png",云南卫视
http://122.96.52.11:8080/gitv_live/G_YUNNAN/G_YUNNAN.m3u8.m3u8
#EXTINF:-1 tvg-id="zhejiang" tvg-logo="zhejiang.png",浙江卫视
http://122.96.52.11:8080/gitv_live/G_ZHEJIANG/G_ZHEJIANG.m3u8
#EXTINF:-1 tvg-id="travel" tvg-logo="travel.png",旅游卫视
http://122.96.52.11:8080/gitv_live/LYWS/LYWS.m3u8
45 changes: 45 additions & 0 deletions script.iptvtool/resources/language/Chinese (Simple)/strings.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# {{subst:Name}} Media Center language file
# Addon Name: IPTV Tool
# Addon id: script.iptvtool
# Addon Provider: Taxigps
msgid ""
msgstr ""
"Project-Id-Version: {{subst:Name}} Addons\n"
"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: {{subst:Name}} Translation Team\n"
"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgctxt "#30010"
msgid "Enable EPG Service"
msgstr "启用电子节目单服务"

msgctxt "#30011"
msgid "Download EPG for CCTV Channels"
msgstr "下载央视频道电子节目单"

msgctxt "#30012"
msgid "Download EPG for Provincial Channels"
msgstr "下载卫视频道电子节目单"

msgctxt "#30013"
msgid "Download EPG for PHOENIX TV Channels"
msgstr "下载凤凰卫视电子节目单"

msgctxt "#30030"
msgid "IPTV Tool"
msgstr "IPTV Tool"

msgctxt "#30031"
msgid "Open IPTV Tool Settings"
msgstr "打开 IPTV Tool 设置"

msgctxt "#30032"
msgid "Config PVR IPTV Simple Client"
msgstr "配置 PVR IPTV Simple Client"
45 changes: 45 additions & 0 deletions script.iptvtool/resources/language/English/strings.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# {{subst:Name}} Media Center language file
# Addon Name: IPTV Tool
# Addon id: script.iptvtool
# Addon Provider: Taxigps
msgid ""
msgstr ""
"Project-Id-Version: {{subst:Name}} Addons\n"
"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: {{subst:Name}} Translation Team\n"
"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgctxt "#30010"
msgid "Enable EPG Service"
msgstr ""

msgctxt "#30011"
msgid "Download EPG for CCTV Channels"
msgstr ""

msgctxt "#30012"
msgid "Download EPG for Provincial Channels"
msgstr ""

msgctxt "#30013"
msgid "Download EPG for PHOENIX TV Channels"
msgstr ""

msgctxt "#30030"
msgid "IPTV Tool"
msgstr ""

msgctxt "#30031"
msgid "Open IPTV Tool Settings"
msgstr ""

msgctxt "#30032"
msgid "Config PVR IPTV Simple Client"
msgstr ""
1 change: 1 addition & 0 deletions script.iptvtool/resources/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dummy file to make this directory a package.

0 comments on commit 76c96e5

Please sign in to comment.