Project

General

Profile

Migration ยป import.py

Nicolas C, 2014-11-21 14:17

 
1
#!/usr/bin/env python
2
import time
3
import urllib
4
import urllib2
5
import json
6
#Source IP of your TVHeadend Server
7
ipsrc='192.168.0.9'
8
#Target IP
9
ipdst='192.168.0.254'
10
#Old Network Name
11
onn='Astra28'
12
#New Network UUID
13
nnu='7cc8273901fadc4f5e8b65a4bca392fd'
14
url = 'http://'+ipsrc+':9981/api/mpegts/mux/grid?start=0&limit=400'
15
url=urllib2.urlopen(url)
16
json_string=url.read()
17
data = json.loads(json_string)
18
entries = data['entries']
19
if entries:
20
    for entry in entries:
21
        if entry['network']==onn:
22
            print "Creating MUX: ' + entry['name']
23
            conf = { 'enabled' : 'true',
24
                       'epg' : 0,
25
                       'scan_state' : 0,
26
                       'iptv_url' : 'http://'+ipsrc+':9981/stream/mux/' + entry['uuid'],
27
                       'iptv_interface' : 'eth0',
28
                       'iptv_atsc' : '',
29
                       'iptv_muxname' : entry['name'],
30
                       'iptv_sname' : '',
31
                       'charset' : '',
32
                       'pmt_06_ac3' : '',
33
                       'priority' : 0,
34
                       'spriority' : 0,
35
                   }
36
            data = { 'uuid' : nnu,
37
                     'conf' : json.JSONEncoder().encode(conf),
38
                   }
39
            posturl = 'http://'+ipdst+':9981/api/mpegts/network/mux_create'
40
            postdata = urllib.urlencode(data)
41
            req = urllib2.Request(posturl, postdata)
42
            response = urllib2.urlopen(req)
43
            the_page = response.read()
44
            print "Sleeping for 60 seconds to allow initial scan"
45
            time.sleep(60)
    (1-1/1)