From a5e72f0fbdedf251e90334657856f07bca725be0 Mon Sep 17 00:00:00 2001 From: yo momma Date: Tue, 3 Feb 2026 22:05:50 +0000 Subject: Hump.fm: update configs and scripts --- scripts/fill.image_urls.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'scripts/fill.image_urls.py') diff --git a/scripts/fill.image_urls.py b/scripts/fill.image_urls.py index b7e0f2e..d3a10de 100755 --- a/scripts/fill.image_urls.py +++ b/scripts/fill.image_urls.py @@ -5,7 +5,7 @@ import sys import postgresql from urllib.parse import urlparse -db = postgresql.open("pq://postgres:root@localhost/dumpfm") +db = postgresql.open("pq://postgres:root@localhost/humpfm") db.execute("SET CLIENT_ENCODING to 'UNICODE'") def get_num_images_in_db(): @@ -58,15 +58,23 @@ def get_urls_from_messages(messages): return urls # this does 3 things... -# convert 'http://dumpfm.s3.amazonaws.com' to '/' +# convert archive URLs to a shorter local form # drops 'http://' from urls -# drops 'dump.fm/images' from urls +# drops 'hump.fm/images' from urls # the client is expected to rebuild urls based on this heuristic: # if the url starts with '/', prepend '/' # otherwise, prepend 'http://' def make_url_smaller(url): - if url[:37] == 'http://dumpfm.s3.amazonaws.com/images': - url = '/images' + url[37:] + prefixes = [ + 'https://archive.hump.fm/images', + 'http://archive.hump.fm/images', + 'https://s3.amazonaws.com/archive.hump.fm/images', + 'http://s3.amazonaws.com/archive.hump.fm/images', + ] + for prefix in prefixes: + if url[:len(prefix)] == prefix: + url = '/images' + url[len(prefix):] + break if url[:21] == '/images': url = url[21:] else: -- cgit v1.2.3-70-g09d2