Skip to content

Commit

Permalink
Fix regex for Hurtom naming scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
chbgdn committed Mar 30, 2024
1 parent 0809953 commit 73f35f7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
64 changes: 25 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]

- name: Docker Buildx
uses: docker/[email protected]

- name: Login to Docker Hub
uses: docker/[email protected]
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 }}
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const USER_AGENT = `CrossSeed/${PROGRAM_VERSION}`;
export const EP_REGEX =
/^(?<title>.+?)[_.\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"];
Expand Down
13 changes: 12 additions & 1 deletion src/torznab.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 73f35f7

Please sign in to comment.