Project

General

Profile

RE: 2 issues: "No input source available for subscription... ยป hdhr-listing-to-m3u.py

G Kazaroth, 2021-04-14 15:09

 
1

    
2
# this script will convert the hdhomerun listings (channels) to
3
# m3u format for use with external media players. before running
4
# this script, be sure to modify the <<config>> variable settings
5
# below.
6
#
7
# Suggested Usage: This script should be run on a cron to keep
8
# the channel lineup to date. Below is an example of how to execute this script:
9
# python /path/to/script/hdhomerun-prime-listings-to-m3u.py > /path/to/playlist.m3u
10
#
11
# @author Josh Kastang (josh[dot]kastang[at]gmail[dot]com)
12
# @tested Python 2.7, but should work with Python 2.6 as well.
13
#
14

    
15
# use cmd to find all devices:
16
#   hdhomerun_config discover
17

    
18
import requests
19
import json
20
from pprint import pprint
21

    
22
# * hdhr-ip: ip address of your hdhr prime unit
23
# * duration: the duration the stream should play for. some
24
# players seem to require this while others do not. default
25
# is set for 7200 minutes (2 hours)
26
config = {
27
    'hdhr-ip'   : 'HDHR-xxxxxxxx',
28

    
29
    'duration'  : '7200',
30
}
31

    
32
hdhr_url        = "http://{0}/lineup.json?show=unprotected".format(config['hdhr-ip'])
33
response_obj    = requests.get(hdhr_url)
34
listings_res    = response_obj.text
35

    
36
print( "#EXTM3U" )
37
listings = json.loads(listings_res)
38
for l in listings:
39
    channel = l['GuideNumber']
40
    name    = l['GuideName']
41

    
42
    print( "#EXTINF:{0},{1} {2}".format(channel,channel, name) )
43
    print( "http://{0}:5004/auto/v{1}".format(
44
            config['hdhr-ip'],
45
            channel,
46
    ))
47

    
    (1-1/1)