-
-
Save zbyte64/1b6ceef39900bdcd3bd54ec3020fe5dd to your computer and use it in GitHub Desktop.
Convert HDHomeRun Prime Listings to M3U Format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# this script will convert the hdhomerun listings (channels) to | |
# m3u format for use with external media players. before running | |
# this script, be sure to modify the <<config>> variable settings | |
# below. | |
# | |
# Suggested Usage: This script should be run on a cron to keep | |
# the channel lineup to date. Below is an example of how to execute this script: | |
# python /path/to/script/hdhomerun-prime-listings-to-m3u.py > /path/to/playlist.m3u | |
# | |
# @author Josh Kastang (josh[dot]kastang[at]gmail[dot]com) | |
# | |
# Converted to Python 3 and revised to support Jellyfin by Casey Avila | |
import sys | |
import urllib.requests | |
import json | |
# * hdhr-ip: ip address of your hdhr prime unit | |
# * duration: the duration the stream should play for. some | |
# players seem to require this while others do not. default | |
# is set for 7200 minutes (2 hours) | |
config = { | |
'hdhr-ip' : sys.argv[1], | |
'duration' : '7200', | |
} | |
hdhr_url = "http://{}/lineup.json?show=unprotected".format(config['hdhr-ip']) | |
response_obj = urllib.requests.urlopen(hdhr_url) | |
listings_res = response_obj.read() | |
print("#EXTM3U") | |
listings = json.loads(listings_res) | |
for l in listings: | |
channel = l['GuideNumber'] | |
name = l['GuideName'] | |
print('#EXTINF:-1 tvg-chno="{}" tvg-name="{}",{}'.format(channel, name, name)) | |
print("http://{}:5004/auto/v{}?duration={}".format( | |
config['hdhr-ip'], | |
channel, | |
config['duration'] | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment