summaryrefslogtreecommitdiff
path: root/scripts/fill.image_urls.py
diff options
context:
space:
mode:
authoryo momma <shutup@oops.wtf>2026-02-03 22:05:50 +0000
committeryo momma <shutup@oops.wtf>2026-02-03 22:05:50 +0000
commita5e72f0fbdedf251e90334657856f07bca725be0 (patch)
tree2b71e48a1e07b0f4f0edcb8a154769b4069dbf98 /scripts/fill.image_urls.py
parent36202d8defb26f87264914f60c39c768cff3729e (diff)
Hump.fm: update configs and scripts
Diffstat (limited to 'scripts/fill.image_urls.py')
-rwxr-xr-xscripts/fill.image_urls.py18
1 files changed, 13 insertions, 5 deletions
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: