From 73f35f705bc97e67c8b995d6d768a6288eb7689f Mon Sep 17 00:00:00 2001 From: chbgdn Date: Fri, 29 Mar 2024 22:22:27 +0200 Subject: [PATCH] Fix regex for Hurtom naming scheme --- .github/workflows/ci.yml | 64 ++++++++++++++++------------------------ src/constants.ts | 4 +-- src/torznab.ts | 13 +++++++- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19248ef6a..a62cbfbb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,48 +32,34 @@ jobs: environment: Docker Hub runs-on: ubuntu-latest steps: - - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - images: | - ghcr.io/${{ github.repository_owner }}/cross-seed - crossseed/cross-seed - tags: | - type=semver,pattern=version-{{version}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=ref,event=branch - type=ref,event=pr - - - name: Set up QEMU dependency - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to GHCR - if: ${{ !github.event.pull_request.head.repo.fork }} - uses: docker/login-action@v1 + - name: Checkout + uses: actions/checkout@v3 + + - name: Docker Hub Description + uses: peter-evans/dockerhub-description@v3.1.2 with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Login to DockerHub - if: ${{ !github.event.pull_request.head.repo.fork }} - uses: docker/login-action@v1 + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: chbgdn/cross-seed + readme-filepath: ./README.md + short-description: ${{ github.event.repository.description }} + + - name: Setup QEMU + uses: docker/setup-qemu-action@v2.1.0 + + - name: Docker Buildx + uses: docker/setup-buildx-action@v2.4.1 + + - name: Login to Docker Hub + uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v2 + + - name: Build and push + uses: docker/build-push-action@v4 with: - push: ${{ !github.event.pull_request.head.repo.fork }} + context: . + push: true + tags: chbgdn/cross-seed:latest platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/src/constants.ts b/src/constants.ts index 52d294a3e..28f409f19 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -9,9 +9,9 @@ export const USER_AGENT = `CrossSeed/${PROGRAM_VERSION}`; export const EP_REGEX = /^(?.+?)[_.\s-]+(?:(?<season>S\d+)?[_.\s]?(?<episode>E\d+(?:[\s-]?E?\d+)?(?![ip]))(?!\d+[ip])|(?<date>(?<year>\d{4})[_.\s-](?<month>\d{2})[_.\s-](?<day>\d{2})))/i; export const SEASON_REGEX = - /^(?<title>.+?)[_.\s-]+(?<season>S\d+)(?:[_.\s-]*?(?<seasonmax>S?\d+))?(?=[_.\s](?!E\d+))/i; + /^(?:\[.+?\][_.\s])*(?<title>.+?)[_.\s-]+(?<season>S\d+|\(Season\s\d+\))(?:[_.\s-]*?(?<seasonmax>S?\d+))?(?=[_.\s](?!E\d+))/i; export const MOVIE_REGEX = - /^(?<title>.+?)[_.\s][[(]?(?<year>\d{4})[)\]]?(?![pi])/i; + /^(?:\[.+?\][_.\s])*(?<title>.+?)[_.\s][[(]?(?<year>\d{4})[)\]]?(?![pi])/i; export const RELEASE_GROUP_REGEX = /(?<=-)[\w ]+(?=(?:\.\w{1,5})?$)/i; export const VIDEO_EXTENSIONS = [".mkv", ".mp4", ".avi"]; diff --git a/src/torznab.ts b/src/torznab.ts index 6bf4ada9c..35abd47ce 100644 --- a/src/torznab.ts +++ b/src/torznab.ts @@ -1,7 +1,12 @@ import ms from "ms"; import fetch from "node-fetch"; import xml2js from "xml2js"; -import { EP_REGEX, SEASON_REGEX, USER_AGENT } from "./constants.js"; +import { + EP_REGEX, + SEASON_REGEX, + MOVIE_REGEX, + USER_AGENT +} from "./constants.js"; import { db } from "./db.js"; import { CrossSeedError } from "./errors.js"; import { @@ -129,6 +134,12 @@ function createTorznabSearchQuery(name: string, caps: Caps) { q: cleanseSeparators(match.groups.title), season: extractNumber(match.groups.season), } as const; + } else if (mediaType === MediaType.MOVIE && caps.movieSearch) { + const match = nameWithoutExtension.match(MOVIE_REGEX); + return { + t: "search", + q: `${cleanseSeparators(match.groups.title)} ${extractNumber(match.groups.year)}`, + } as const; } else { return { t: "search",