From 603e0d908a3d40ff3a4f66e26ca8c684e59d27bb Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Fri, 27 Nov 2020 16:24:58 -0500 Subject: [PATCH 01/11] Update to use SXMAUTHNEW cookie Getting "Unable to authenticate because login failed" when trying to connect. Could login successfully using https://player.siriusxm.com so credentials were correct. Examining the cookies within the browser seem to indicate that SXM changed "SXMAUTH" to "SXMAUTHNEW". Updated code and was able to list/play channels. --- sxm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sxm.py b/sxm.py index 398b480..7019f7c 100644 --- a/sxm.py +++ b/sxm.py @@ -25,7 +25,7 @@ def log(x): print('{} : {}'.format(datetime.datetime.now().strftime('%d.%b %Y %H:%M:%S'), x)) def is_logged_in(self): - return 'SXMAUTH' in self.session.cookies + return 'SXMAUTHNEW' in self.session.cookies def is_session_authenticated(self): return 'AWSELB' in self.session.cookies and 'JSESSIONID' in self.session.cookies From f5ae2b8d71a81a0ec536729b90d952028ea5b4f1 Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:51:11 -0500 Subject: [PATCH 02/11] Get credentials from environment variables Added ability to use the -e or --env parameter to override the command line username and password with the optional SXM_USER and SXM_PASS environment variables. This paired with a proper EnvironmentFile in a systemd unit, allows for a secure way of storing your credentials. --- sxm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sxm.py b/sxm.py index 7019f7c..8ac7354 100644 --- a/sxm.py +++ b/sxm.py @@ -5,6 +5,7 @@ import json import time, datetime import sys +import os from http.server import BaseHTTPRequestHandler, HTTPServer class SiriusXM: @@ -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))))) From 63326b094824688672253c1162435a95a0fb2e57 Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Thu, 10 Dec 2020 12:52:46 -0500 Subject: [PATCH 03/11] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 553e8b0..04b5c26 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # SiriusXM +This is forked from andrew0 with minimal changes: + +* Updated cookie name (so that the system actually authenticates now...) +* 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". + +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` From 3ed4bc4498fa5a1337ee84e371746de2a9d2d4ac Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Thu, 10 Dec 2020 13:10:04 -0500 Subject: [PATCH 04/11] Sxm service files (#1) * Create sxm.service * Create override.conf This is my personal unit file override.conf. The script is in a different location, I run it as the "mpd" user (it's part of my mpd-based whole house audio system), and I load the user name and password from an environment file. * Update README.md Added details about systemd unit files --- README.md | 1 + override.conf | 7 +++++++ sxm.service | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 override.conf create mode 100644 sxm.service diff --git a/README.md b/README.md index 04b5c26..7a5b73a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This is forked from andrew0 with minimal changes: * Updated cookie name (so that the system actually authenticates now...) * 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 geric systemd unit file and an override file customized for my use case. Original Readme: diff --git a/override.conf b/override.conf new file mode 100644 index 0000000..42ff3d1 --- /dev/null +++ b/override.conf @@ -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 diff --git a/sxm.service b/sxm.service new file mode 100644 index 0000000..8ff99aa --- /dev/null +++ b/sxm.service @@ -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/fts-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 From 6f17c9a3c12ef730e3d76f41873e534019383e66 Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:28:33 -0500 Subject: [PATCH 05/11] Update README.md Another update to keep up with SXM cookie changes --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a5b73a..0fc8bc3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ This is forked from andrew0 with minimal changes: -* Updated cookie name (so that the system actually authenticates now...) +* Updated SXM auth cookie name (so that the system actually authenticates now...) +* Updated AWS cookie name (again, si 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 geric systemd unit file and an override file customized for my use case. From 8f1810f2ff3fa952dc912709961d48842389ef80 Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:31:12 -0500 Subject: [PATCH 06/11] Update AWS cookie name to confirm authentication --- sxm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sxm.py b/sxm.py index 8ac7354..8d34507 100644 --- a/sxm.py +++ b/sxm.py @@ -29,7 +29,7 @@ def is_logged_in(self): return 'SXMAUTHNEW' 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(): From a269e03a178cc4a349d18196596511863fe88ad5 Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:33:32 -0500 Subject: [PATCH 07/11] Update README.md Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fc8bc3..fe49aa0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is forked from andrew0 with minimal changes: * Updated SXM auth cookie name (so that the system actually authenticates now...) -* Updated AWS cookie name (again, si that it actually authenticates 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 geric systemd unit file and an override file customized for my use case. From d72b38b3d723acb015e4ab5bfb5764ebc9099474 Mon Sep 17 00:00:00 2001 From: fts-tmassey <62904731+fts-tmassey@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:33:59 -0500 Subject: [PATCH 08/11] Update README.md Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe49aa0..eb099d5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is forked from andrew0 with minimal changes: * 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 geric systemd unit file and an override file customized for my use case. +* I added a generic systemd unit file and an override file customized for my use case. Original Readme: From 8ed7fc794c8c3db6e633074920bf383449f4de18 Mon Sep 17 00:00:00 2001 From: MiM-TMassey <35174197+MiM-TMassey@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:15:22 -0500 Subject: [PATCH 09/11] Update auth cookie to SXMDATA SXM changed the name of their auth cookie again: updated cookie name to reflect chane. --- sxm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sxm.py b/sxm.py index 8d34507..8a1e728 100644 --- a/sxm.py +++ b/sxm.py @@ -26,7 +26,7 @@ def log(x): print('{} : {}'.format(datetime.datetime.now().strftime('%d.%b %Y %H:%M:%S'), x)) def is_logged_in(self): - return 'SXMAUTHNEW' in self.session.cookies + return 'SXMDATA' in self.session.cookies def is_session_authenticated(self): return 'AWSALB' in self.session.cookies and 'JSESSIONID' in self.session.cookies From 6ecb874aeb6cdb1d1273ad2c0c65e0c0bcb25cb1 Mon Sep 17 00:00:00 2001 From: MiM-TMassey <35174197+MiM-TMassey@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:16:10 -0500 Subject: [PATCH 10/11] Update README.md to reflect latest auth change SXM changed the name of their auth cookie again. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eb099d5..450e801 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ 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". From 7a4f1ed1256f2350fc6ad907ff86e7938d280f7e Mon Sep 17 00:00:00 2001 From: MiM-TMassey <35174197+MiM-TMassey@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:48:31 -0500 Subject: [PATCH 11/11] Update sxm.service Pointed to proper forked GitHub repo --- sxm.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sxm.service b/sxm.service index 8ff99aa..3c85f3e 100644 --- a/sxm.service +++ b/sxm.service @@ -1,7 +1,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later # sxm.py Orginal code: https://github.com/andrew0/SiriusXM -# Updated fork at: https://github.com/fts-tmassey/SiriusXM +# Updated fork at: https://github.com/mim-tmassey/SiriusXM # [Unit] Description=SiriusXM Channel Service