Capture upstream HLS PROGRAM-DATE-TIME per segment and emit atomic per-channel PDT file on .aac requests#79
Conversation
Agent-Logs-Url: https://github.com/paul-1/plugin-SiriusXM/sessions/25d4d8bf-217c-4941-a1a6-967bebfa9a09 Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
.aac requests
Agent-Logs-Url: https://github.com/paul-1/plugin-SiriusXM/sessions/cdc43f7f-912c-48c8-b249-3f8497366925 Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
Implemented in bf85f07: Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot lets move this file storage to $TMPDIR/siriusxm/pdt_<channel_id>.txt tmp directories are often ramdisks and we do not have to worry about frequent writes. |
Agent-Logs-Url: https://github.com/paul-1/plugin-SiriusXM/sessions/22899720-e844-4291-8103-b37bd75fc26e Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
Done in c31b477. PDT files now read/write at Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
paul-1
left a comment
There was a problem hiding this comment.
@copilot getting this error
[19.04.2026 13:38:39.757] DEBUG SiriusXM::write_segment_pdt_file:2240: Could not create PDT directory /tmp/siriusxm for channel 9450: Undefined subroutine &SiriusXM::make_path called at /opt/slimserver/Cache/InstalledPlugins/Plugins/SiriusXM/Bin/sxm.pl line 2236.
Agent-Logs-Url: https://github.com/paul-1/plugin-SiriusXM/sessions/eb983754-bc68-4c03-8a49-6322b34df90f Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
Fixed in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
SiriusXMpackage contextOriginal prompt
Repository: paul-1/plugin-SiriusXM
Goal
Implement capturing upstream HLS
#EXT-X-PROGRAM-DATE-TIMEvalues per segment and, when a client requests a segment (.aac), atomically write the actual upstream program date/time for that segment to a temp filecache_dir/pdt_<channel_id>.txtso another process can track current playlist time.Context
Plugins/SiriusXM/Bin/sxm.pl(main branch).handle_http_requestfor paths matching\.aac$, which calls$sxm->get_cached_segment($segment_path, $channel_id)when channel_id can be extracted.extract_segments_from_playlist($content, $channel_id)by scanning for#EXTINFthen consuming the following.aacURI; it does NOT currently parse#EXT-X-PROGRAM-DATE-TIME.Required changes
Add data structure to store upstream PDT per segment.
new), add a hash (e.g.segment_pdt => {}) keyed by channel_id then segment URI.Update
extract_segments_from_playlist($content, $channel_id)to parse upstream PDT.#EXT-X-PROGRAM-DATE-TIME:<iso8601>line encountered..aacsegment URI is captured (the line after#EXTINF:), also store the PDT for that segment in the mapping:$self->{segment_pdt}{$channel_id}{$segment_uri} = $current_pdt.#EXTINF(common). Do not overwrite segment mapping later.Add helper to write the current segment’s PDT to disk.
write_segment_pdt_file($channel_id, $segment_path)in the SiriusXM package.cache_diras the directory containing$main::CONFIG{cookiefile}(same approach used elsewhere for channels.json/server_state.json). UsedirnameandFile::Spec->catfile.${cache_dir}/pdt_<channel_id>.txt.tmpthenrenameto${cache_dir}/pdt_<channel_id>.txtfor atomic update.Call PDT file writer on each segment request.
get_cached_segment($segment_path, $channel_id), after tracking last requested segment ($self->{last_segment}{$channel_id} = $segment_path;), call the writer so it runs whether segment is served from cache or fetched.Safety/robustness
Acceptance criteria
#EXT-X-PROGRAM-DATE-TIME, and a client later requests a segment present in that playlist, the code writescache_dir/pdt_<channel_id>.txtwith that exact upstream value.Files
Plugins/SiriusXM/Bin/sxm.plReference

The following is the prior conversation context from the user's chat exploration (may be truncated):
User: When caching the segments, can we also include and entry containing #EXT-X-PROGRAM-DATE-TIME with the segment
Assistant: Yes — you can include
#EXT-X-PROGRAM-DATE-TIME“with the segment”, but it shouldn’t be stored inside the binary segment cache entry. Instead, store it as metadata alongside the cached segment, and then emit it in the generated.m3u8right before the corresponding#EXTINF/URI line.Why this way (fits your current code)
Right now
cache_next_segment()only caches raw bytes:get_segment($segment_path)$self->{segment_cache}->{$channel_id}->{$segment_path} = $segment_data;citeturn1search1There’s no existing handling of
#EXT-X-PROGRAM-DATE-TIMEin the codebase (no matches), so the playlist parser/generator would need to be extended anyway. citeturn1search0Suggested shape
Keep segment bytes as-is, and add another structure, e.g.:
$self->{segment_program_date_time}->{$channel_id}->{$segment_path} = $iso8601_time;Then, wherever you build the cached playlist (
playlist_cache/ playlist generation code), when outputting each segment line:#EXT-X-PROGRAM-DATE-TIME:<value>#EXTINFand segment URI.One key question (so it’s correct)
Do you want the
#EXT-X-PROGRAM-DATE-TIMEvalue to be:If you tell me which one you want, I can point you to the exact playlist parse/generation area in
sxm.plthat needs to be updated and what to store per segment.User: I want to retain the upstream program date. The client will still be requesting ...
This pull request was created from Copilot chat.