Skip to content

Commit

Permalink
Merge pull request #31 from iPromKnight/hotfix/indexer_support
Browse files Browse the repository at this point in the history
fix: Ensure infohashes only 40 chars in results
  • Loading branch information
iPromKnight authored Nov 12, 2024
2 parents c9195cc + cb4ae26 commit 218ea74
Show file tree
Hide file tree
Showing 8 changed files with 559 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/conventional-commits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Conventional Commits

on:
pull_request:
branches: [ main ]

jobs:
build:
name: Conventional Commits
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: webiny/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Release Please"

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "2.0.1"
}
25 changes: 25 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"release-type": "simple",
"extra-files": ["Directory.Build.props"],
"changelog-sections": [
{ "type": "feat", "section": "🚀 New Features", "hidden": false },
{ "type": "feature", "section": "🚀 New Features", "hidden": false },
{ "type": "enhance", "section": "💅 Enhancements", "hidden": false },
{ "type": "fix", "section": "🔥 Bug Fixes", "hidden": false },
{ "type": "perf", "section": "🏃 Performance Improvements", "hidden": false },
{ "type": "revert", "section": "↩️ Reverts", "hidden": true },
{ "type": "docs", "section": "📚 Documentation", "hidden": false },
{ "type": "style", "section": "🎨 Code Style", "hidden": false },
{ "type": "chore", "section": "⚙️ Chores", "hidden": false },
{ "type": "refactor", "section": "⌨️ Code Refactoring", "hidden": false },
{ "type": "test", "section": "🧪 Automated Testing", "hidden": false },
{ "type": "build", "section": "🛠️ Build System", "hidden": false },
{ "type": "ci", "section": "📦 CI Improvements", "hidden": false }
]
}
}
}
149 changes: 149 additions & 0 deletions src/Zilean.Database/Functions/SearchImdbProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,155 @@ ORDER BY
$$ LANGUAGE plpgsql;
""";

internal const string CreateTorrentProcedureV2 =
"""
CREATE OR REPLACE FUNCTION search_torrents_meta(
query TEXT DEFAULT NULL,
season INT DEFAULT NULL,
episode INT DEFAULT NULL,
year INT DEFAULT NULL,
language TEXT DEFAULT NULL,
resolution TEXT DEFAULT NULL,
imdbId TEXT DEFAULT NULL,
limit_param INT DEFAULT 20,
similarity_threshold REAL DEFAULT 0.85
)
RETURNS TABLE(
"InfoHash" TEXT,
"Resolution" TEXT,
"Year" INT,
"Remastered" BOOLEAN,
"Codec" TEXT,
"Audio" TEXT[],
"Quality" TEXT,
"Episodes" INT[],
"Seasons" INT[],
"Languages" TEXT[],
"ParsedTitle" TEXT,
"NormalizedTitle" TEXT,
"RawTitle" TEXT,
"Size" TEXT,
"Category" TEXT,
"Complete" BOOLEAN,
"Volumes" INT[],
"Hdr" TEXT[],
"Channels" TEXT[],
"Dubbed" BOOLEAN,
"Subbed" BOOLEAN,
"Edition" TEXT,
"BitDepth" TEXT,
"Bitrate" TEXT,
"Network" TEXT,
"Extended" BOOLEAN,
"Converted" BOOLEAN,
"Hardcoded" BOOLEAN,
"Region" TEXT,
"Ppv" BOOLEAN,
"Is3d" BOOLEAN,
"Site" TEXT,
"Proper" BOOLEAN,
"Repack" BOOLEAN,
"Retail" BOOLEAN,
"Upscaled" BOOLEAN,
"Unrated" BOOLEAN,
"Documentary" BOOLEAN,
"EpisodeCode" TEXT,
"Country" TEXT,
"Container" TEXT,
"Extension" TEXT,
"Torrent" BOOLEAN,
"Score" REAL,
"ImdbId" TEXT,
"ImdbCategory" TEXT,
"ImdbTitle" TEXT,
"ImdbYear" INT,
"ImdbAdult" BOOLEAN
) AS $$
BEGIN
EXECUTE format('SET pg_trgm.similarity_threshold = %L', similarity_threshold);

RETURN QUERY
SELECT
t."InfoHash",
t."Resolution",
t."Year",
t."Remastered",
t."Codec",
t."Audio",
t."Quality",
t."Episodes",
t."Seasons",
t."Languages",
t."ParsedTitle",
t."NormalizedTitle",
t."RawTitle",
t."Size",
t."Category",
t."Complete",
t."Volumes",
t."Hdr",
t."Channels",
t."Dubbed",
t."Subbed",
t."Edition",
t."BitDepth",
t."Bitrate",
t."Network",
t."Extended",
t."Converted",
t."Hardcoded",
t."Region",
t."Ppv",
t."Is3d",
t."Site",
t."Proper",
t."Repack",
t."Retail",
t."Upscaled",
t."Unrated",
t."Documentary",
t."EpisodeCode",
t."Country",
t."Container",
t."Extension",
t."Torrent",
similarity(t."ParsedTitle", query) AS "Score",
t."ImdbId",
i."Category" AS "ImdbCategory",
i."Title" AS "ImdbTitle",
i."Year" AS "ImdbYear",
i."Adult" AS "ImdbAdult"
FROM
public."Torrents" t
LEFT JOIN
public."ImdbFiles" i ON t."ImdbId" = i."ImdbId"
WHERE
Length(t."InfoHash") = 40
AND
(query IS NULL OR t."ParsedTitle" % query)
AND (season IS NULL OR season = ANY(t."Seasons"))
AND (
(episode IS NULL AND season IS NOT NULL)
OR
(
episode IS NOT NULL AND
season IS NOT NULL AND
(episode = ANY(t."Episodes") OR t."Episodes" IS NULL OR t."Episodes" = '{}')
)
OR (season IS NULL AND episode IS NULL)
)
AND (year IS NULL OR t."Year" BETWEEN year - 1 AND year + 1)
AND (language IS NULL OR language = ANY(t."Languages"))
AND (resolution IS NULL OR resolution = t."Resolution")
AND (imdbId IS NULL OR t."ImdbId" = imdbId)
ORDER BY
"Score" DESC
LIMIT
limit_param;
END;
$$ LANGUAGE plpgsql;
""";

internal const string RemoveImdbProcedure = "DROP FUNCTION IF EXISTS search_imdb_meta(TEXT, TEXT, INT, INT);";
internal const string RemoveTorrentProcedure = "DROP FUNCTION IF EXISTS search_torrents_meta(TEXT, INT, INT, INT, TEXT, TEXT, TEXT, INT, REAL);";
}
Loading

0 comments on commit 218ea74

Please sign in to comment.