bug fixes

This commit is contained in:
G. Gibson 2026-09-08 21:10:23 -07:00
commit 8fa42f2376
2 changed files with 42 additions and 35 deletions

View file

@ -207,41 +207,48 @@ def parse_feed(opts)
} }
end end
def register_show(show_title, feed_url, archive_flag = 0, opml_flag = 0) def register_show(show_title, feed_url, archive: false, opml_import: false)
url = feed_url.to_s.strip
return false if url.empty?
existing = $db_s[:shows].where(feed_url: url).first
if existing
# Update archive/opml flags if they changed
if existing[:archive] != archive_flag || existing[:opml_import] != opml_flag
$db_s[:shows].where(guid: existing[:guid]).update(
archive: archive_flag,
opml_import: opml_flag
)
log("DEBUG", "Updated flags for #{existing[:slug]}: archive=#{archive_flag}, opml=#{opml_flag}")
end
return existing
end
title = show_title.to_s.strip title = show_title.to_s.strip
slug = generate_slug(title) url = feed_url.to_s.strip
slug = "show_#{Digest::SHA1.hexdigest(url)[0,8]}" if slug.empty? return nil if title.empty? || url.empty?
slug = title.downcase.gsub(/[^a-z0-9]+/, "_").gsub(/^_+|_+$/, "")
slug = "show" if slug.empty?
# Check for slug collision with a different feed URL
existing_slug = $db_s[:shows].where(slug: slug).first
if existing_slug && existing_slug[:feed_url] != url
# Append a short hash of the URL to disambiguate
suffix = Digest::SHA1.hexdigest(url)[0, 6]
slug = "#{slug}_#{suffix}"
end
guid = gen_guid(url) guid = gen_guid(url)
now = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S") now = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S")
existing = $db_s[:shows].where(guid: guid).first
if existing
$db_s[:shows].where(guid: guid).update(
title: title,
slug: slug,
feed_url: url,
archive: archive ? 1 : 0,
opml_import: opml_import ? 1 : 0
)
else
$db_s[:shows].insert( $db_s[:shows].insert(
guid: guid, guid: guid,
slug: slug, slug: slug,
title: title, title: title,
feed_url: url, feed_url: url,
archive: archive_flag, archive: archive ? 1 : 0,
opml_import: opml_flag, opml_import: opml_import ? 1 : 0,
created_at: now created_at: now
) )
log("INFO", "Registered show: #{slug} (#{title})") end
$db_s[:shows].where(guid: guid).first
log("INFO", "Registered: #{title} (#{slug})")
true
end end
def sync_gpodder def sync_gpodder

View file

@ -184,10 +184,10 @@ EOF
systemctl daemon-reload systemctl daemon-reload
echo "==> Installed ${UNIT_PATH}" echo "==> Installed ${UNIT_PATH}"
# After the mkdir -p "$STORAGE/state" line, add: # After the mkdir -p "$STORAGE/state" line, add:
mkdir -p "$STORAGE/state" mkdir -p "$STORAGE_ROOT/state"
chown -R liquidsoap:liquidsoap "$STORAGE/state" chown -R liquidsoap:liquidsoap "$STORAGE_ROOT/state"
chmod 755 "$STORAGE/state" chmod 755 "$STORAGE_ROOT/state"
chmod 664 "$STORAGE/state/"*.db 2>/dev/null || true chmod 664 "$STORAGE_ROOT/state/"*.db 2>/dev/null || true
# --- Cron entries (liquidsoap user's crontab already exists from package) ----- # --- Cron entries (liquidsoap user's crontab already exists from package) -----
CRON_FETCH="0 * * * * cd ${INSTALL_DIR} && ${INSTALL_DIR}/run_radio.sh fetch_podcasts.rb --fetch-all >> ${STORAGE_ROOT}/logs/fetch_cron.log 2>&1" CRON_FETCH="0 * * * * cd ${INSTALL_DIR} && ${INSTALL_DIR}/run_radio.sh fetch_podcasts.rb --fetch-all >> ${STORAGE_ROOT}/logs/fetch_cron.log 2>&1"