diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 0000000..67d3ae8 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,43 @@ +name: Docker Build and Push + +on: + push: + branches: [ "master", "main" ] + pull_request: + branches: [ "master", "main" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index ac1be34..e3eeba9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM debian:sid-slim +FROM debian:bookworm-slim ENTRYPOINT ["bash"] RUN apt-get update && \ - apt-get --no-install-recommends -y install file less bash coreutils gawk sed grep calibre p7zip-full tesseract-ocr tesseract-ocr-osd tesseract-ocr-eng python-lxml poppler-utils catdoc djvulibre-bin locales curl ca-certificates && \ + apt-get --no-install-recommends -y install file less bash coreutils gawk sed grep calibre p7zip-full tesseract-ocr tesseract-ocr-osd tesseract-ocr-eng python3-lxml poppler-utils catdoc djvulibre-bin locales curl ca-certificates && \ rm -rf /var/lib/apt/lists/* && \ localedef -i en_US -c -f UTF-8 en_US.UTF-8 && \ useradd -mUs /usr/bin/bash -u 1000 user && \ @@ -16,8 +16,8 @@ ENV LANG="en_US.UTF-8" PATH="${PATH}:/ebook-tools" USER user -RUN curl 'https://www.mobileread.com/forums/attachment.php?attachmentid=163537' > goodreads.zip && \ - sha256sum 'goodreads.zip' | grep -q 'c44f88222017aaad0aa1a674e69f46b309198269c7f13ebd671ae942052d45a8' && \ +RUN curl 'https://www.mobileread.com/forums/attachment.php?attachmentid=208844' > goodreads.zip && \ + sha256sum 'goodreads.zip' | grep -q '7201fd243958ff91960998ac1f9b70bea196d6f386b1e2acf5ba42184c3b9821' && \ calibre-customize --add-plugin goodreads.zip && \ rm goodreads.zip && \ curl -L 'https://github.com/na--/calibre-worldcat-xisbn-metadata-plugin/archive/0.1.zip' > worldcat.zip && \ diff --git a/README.md b/README.md index 0aa4f20..4f60dea 100644 --- a/README.md +++ b/README.md @@ -53,14 +53,14 @@ You need recent versions of: The scripts are only tested on linux, though they should work on any *nix system that has the needed dependencies. You can install everything needed with this command in Arch Linux: ```bash - pacman -S file less bash coreutils gawk sed grep calibre p7zip tesseract tesseract-data-eng python2-lxml poppler catdoc djvulibre + pacman -S file less bash coreutils gawk sed grep calibre p7zip tesseract tesseract-data-eng python-lxml poppler catdoc djvulibre ``` *Note: you can probably get much better OCR results by using the unstable 4.0 version of Tesseract. It is present in the [AUR](https://aur.archlinux.org/packages/tesseract-git/) or you can easily make a package like [this](https://github.com/na--/custom-archlinux-packages/blob/master/tesseract-4-bundle-git/PKGBUILD) yourself.* Here is how to install the packages on Debian (and Debian-based distributions like Ubuntu): ```bash - apt-get install file less bash coreutils gawk sed grep calibre p7zip-full tesseract-ocr tesseract-ocr-osd tesseract-ocr-eng python-lxml poppler-utils catdoc djvulibre-bin + apt-get install file less bash coreutils gawk sed grep calibre p7zip-full tesseract-ocr tesseract-ocr-osd tesseract-ocr-eng python3-lxml poppler-utils catdoc djvulibre-bin ``` *Keep in mind that a lot of debian-based distributions do not have up-to-date packages and the scripts work best when calibre's version is at least 2.84. For earlier versions you have to set `ISBN_METADATA_FETCH_ORDER` and `ORGANIZE_WITHOUT_ISBN_SOURCES` to empty strings.* diff --git a/rename-calibre-library.sh b/rename-calibre-library.sh index cb718bc..cecb00d 100755 --- a/rename-calibre-library.sh +++ b/rename-calibre-library.sh @@ -24,7 +24,7 @@ if [[ "$#" == "0" ]]; then fi gm() { - python2 -c "from lxml.etree import parse; from sys import stdin; print((u'\\n'.join(parse(stdin).xpath('$2'))).encode('utf-8'))" < "$1" + python3 -c "from lxml.etree import parse; from sys import stdin; print('\n'.join(parse(stdin.buffer).xpath('$2')))" < "$1" } find "$@" -type f ! -name "*.opf" ! -name "cover.jpg" -print0 | sort -z ${FILE_SORT_FLAGS[@]:+"${FILE_SORT_FLAGS[@]}"} | while IFS= read -r -d '' book_path