Download the file directly for book covers
- ID
6e296bb- date
2024-01-13 23:28:59+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
1fa104f- message
Download the file directly for book covers- changed files
2 files, 12 additions, 12 deletions
Changed files
images/README.md (11197) → images/README.md (11201)
diff --git a/images/README.md b/images/README.md
index c7b539e..2bc3dfb 100644
--- a/images/README.md
+++ b/images/README.md
@@ -77,6 +77,13 @@ scripts = [
"""
},
{
+ "name": "download_cover_image",
+ "description": """
+ copy an image from my Desktop folder into my book tracker.
+ This is very specific to my setup and unlikely to be useful to anyone else.
+ """
+ },
+ {
"usage": "images_only_pdf.py [PATH]",
"description": """
take a PDF, and create a new PDF which just has the images filling the page.
@@ -104,13 +111,6 @@ scripts = [
"""
},
{
- "name": "move_cover_image",
- "description": """
- copy an image from my Desktop folder into my book tracker.
- This is very specific to my setup and unlikely to be useful to anyone else.
- """
- },
- {
"usage": "pdfthumb.py [PATH] --page=[PAGE]",
"description": """
get a PNG thumbnail of a specific page of a PDF, for example <code>pdfthumb pattern.pdf --page=3</code> will create a thumbnail of the third page.
images/move_cover_image (848) → images/download_cover_image (821)
diff --git a/images/move_cover_image b/images/download_cover_image
similarity index 81%
rename from images/move_cover_image
rename to images/download_cover_image
index 34f435c..48f4ea4 100755
--- a/images/move_cover_image
+++ b/images/download_cover_image
@@ -1,14 +1,12 @@
#!/usr/bin/env bash
-# Copy an image from my Desktop folder into my book tracker.
+# Copy an image from my open browser tab into my book tracker.
#
# This is very specific to my setup and unlikely to be useful to anyone else.
set -o errexit
set -o nounset
-LATEST_DOWNLOAD=$(latest_download)
LATEST_REVIEW=$(git ls-files -o --exclude-standard)
-echo "$LATEST_DOWNLOAD"
if [[ "$LATEST_REVIEW" = "" ]]
then
@@ -21,7 +19,9 @@ echo "$LATEST_REVIEW"
filename=$(basename -- "$LATEST_REVIEW" .md)
year=$(basename -- $(dirname -- "$LATEST_REVIEW"))
-image_filename=$(basename -- "$LATEST_DOWNLOAD")
+url="$(/Users/alexwlchan/.cargo/bin/safari url)"
+
+image_filename=$(basename -- "$url")
image_extension="${image_filename##*.}"
image_path=~/repos/books.alexwlchan.net/src/covers/$year/$filename.$image_extension
@@ -29,5 +29,5 @@ image_path=~/repos/books.alexwlchan.net/src/covers/$year/$filename.$image_extens
mkdir -p "$(dirname "$image_path")"
echo "$image_path"
-mv "$LATEST_DOWNLOAD" "$image_path"
+curl "$url" > "$image_path"
dominant_colours "$image_path"