Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# SiriusXM

This is forked from andrew0 with minimal changes:

* Updated SXM auth cookie name (so that the system actually authenticates now...)
* 20240131 And changed it again...
* Updated AWS cookie name (again, so that it actually authenticates again...)
* Added -e (--env) parameter to use SXM_USER and SXM_PASS environment variables to override username and password on command line
* Note: The username and password parameters are still required: just put something like "user" and "pass".
* I added a generic systemd unit file and an override file customized for my use case.

Original Readme:

This script creates a server that serves HLS streams for SiriusXM channels. To use it, pass your SiriusXM username and password and a port to run the server on. For example, you start the server by running:
`python3 sxm.py myuser mypassword -p 8888`

Expand Down
7 changes: 7 additions & 0 deletions override.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Service]
WorkingDirectory=/data/mpd/tools/sxm
EnvironmentFile=/data/mpd/tools/sxm/id
User=mpd
ExecStart=
# NOTE: With EnvironmentFile and the -e parameter, user and pw are ignored.
ExecStart=/usr/bin/python3 /data/mpd/tools/sxm/sxm.py user pw -e -p 8888
13 changes: 10 additions & 3 deletions sxm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import time, datetime
import sys
import os
from http.server import BaseHTTPRequestHandler, HTTPServer

class SiriusXM:
Expand All @@ -25,10 +26,10 @@ def log(x):
print('{} <SiriusXM>: {}'.format(datetime.datetime.now().strftime('%d.%b %Y %H:%M:%S'), x))

def is_logged_in(self):
return 'SXMAUTH' in self.session.cookies
return 'SXMDATA' in self.session.cookies

def is_session_authenticated(self):
return 'AWSELB' in self.session.cookies and 'JSESSIONID' in self.session.cookies
return 'AWSALB' in self.session.cookies and 'JSESSIONID' in self.session.cookies

def get(self, method, params, authenticate=True):
if authenticate and not self.is_session_authenticated() and not self.authenticate():
Expand Down Expand Up @@ -355,8 +356,14 @@ def do_GET(self):
parser.add_argument('password')
parser.add_argument('-l', '--list', required=False, action='store_true', default=False)
parser.add_argument('-p', '--port', required=False, default=9999, type=int)
parser.add_argument('-e', '--env', required=False, action='store_true', default=False)
args = vars(parser.parse_args())

if args['env']:
if "SXM_USER" in os.environ:
args['username'] = os.environ.get('SXM_USER')
if "SXM_PASS" in os.environ:
args['password'] = os.environ.get('SXM_PASS')

sxm = SiriusXM(args['username'], args['password'])
if args['list']:
channels = list(sorted(sxm.get_channels(), key=lambda x: (not x.get('isFavorite', False), int(x.get('siriusChannelNumber', 9999)))))
Expand Down
25 changes: 25 additions & 0 deletions sxm.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# sxm.py Orginal code: https://github.com/andrew0/SiriusXM
# Updated fork at: https://github.com/mim-tmassey/SiriusXM
#
[Unit]
Description=SiriusXM Channel Service
Requires=network.target

[Service]
WorkingDirectory=/usr/local/sxm
Type=exec
ExecStart=/usr/bin/python3 /usr/local/sxm/sxm.py user password -p 8888
Restart=always
# disallow writing to /usr, /bin, /sbin, ...
ProtectSystem=yes
# more paranoid security settings
ProtectKernelTunables=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
RestrictNamespaces=yes

[Install]
WantedBy=multi-user.target