mirror of
https://github.com/mistergibson/radio.git
synced 2026-09-08 22:09:51 -07:00
bug fixes
This commit is contained in:
parent
4d9201bf24
commit
8fa42f2376
2 changed files with 42 additions and 35 deletions
|
|
@ -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
|
title = show_title.to_s.strip
|
||||||
return false if url.empty?
|
url = feed_url.to_s.strip
|
||||||
|
return nil if title.empty? || url.empty?
|
||||||
|
|
||||||
existing = $db_s[:shows].where(feed_url: url).first
|
slug = title.downcase.gsub(/[^a-z0-9]+/, "_").gsub(/^_+|_+$/, "")
|
||||||
if existing
|
slug = "show" if slug.empty?
|
||||||
# Update archive/opml flags if they changed
|
|
||||||
if existing[:archive] != archive_flag || existing[:opml_import] != opml_flag
|
# Check for slug collision with a different feed URL
|
||||||
$db_s[:shows].where(guid: existing[:guid]).update(
|
existing_slug = $db_s[:shows].where(slug: slug).first
|
||||||
archive: archive_flag,
|
if existing_slug && existing_slug[:feed_url] != url
|
||||||
opml_import: opml_flag
|
# Append a short hash of the URL to disambiguate
|
||||||
)
|
suffix = Digest::SHA1.hexdigest(url)[0, 6]
|
||||||
log("DEBUG", "Updated flags for #{existing[:slug]}: archive=#{archive_flag}, opml=#{opml_flag}")
|
slug = "#{slug}_#{suffix}"
|
||||||
end
|
|
||||||
return existing
|
|
||||||
end
|
end
|
||||||
|
|
||||||
title = show_title.to_s.strip
|
|
||||||
slug = generate_slug(title)
|
|
||||||
slug = "show_#{Digest::SHA1.hexdigest(url)[0,8]}" if slug.empty?
|
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
$db_s[:shows].insert(
|
existing = $db_s[:shows].where(guid: guid).first
|
||||||
guid: guid,
|
if existing
|
||||||
slug: slug,
|
$db_s[:shows].where(guid: guid).update(
|
||||||
title: title,
|
title: title,
|
||||||
feed_url: url,
|
slug: slug,
|
||||||
archive: archive_flag,
|
feed_url: url,
|
||||||
opml_import: opml_flag,
|
archive: archive ? 1 : 0,
|
||||||
created_at: now
|
opml_import: opml_import ? 1 : 0
|
||||||
)
|
)
|
||||||
log("INFO", "Registered show: #{slug} (#{title})")
|
else
|
||||||
$db_s[:shows].where(guid: guid).first
|
$db_s[:shows].insert(
|
||||||
|
guid: guid,
|
||||||
|
slug: slug,
|
||||||
|
title: title,
|
||||||
|
feed_url: url,
|
||||||
|
archive: archive ? 1 : 0,
|
||||||
|
opml_import: opml_import ? 1 : 0,
|
||||||
|
created_at: now
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
log("INFO", "Registered: #{title} (#{slug})")
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync_gpodder
|
def sync_gpodder
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue