Skip to content

Commit 857c2d6

Browse files
committed
SCRAPER: When scanning series, re-rank IMDB search results so that tv-series are higher than movies when detecting the IMDB entry
- closes #61 increase version to v1.4.0-b6
1 parent ac1de2b commit 857c2d6

File tree

7 files changed

+66
-34
lines changed

7 files changed

+66
-34
lines changed

DONE.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,33 @@
22

33
## next (v1.4.0-b6)
44

5-
## v1.4.0-b5
5+
## v1.4.0-b6
66

7-
## Features
7+
## IMDB Scraper
8+
9+
- [x] SCRAPER: When scanning series, re-rank IMDB search results so that tv-series are higher than movies when detecting the IMDB entry
10+
- closes #61
11+
12+
# Older Releases (click to expand)
13+
14+
<details>
15+
<summary>v1.4.0-b5</summary>
16+
17+
## Features (v1.4.0-b5)
818

919
- [x] FEAT: do an update check on the beta channel if the build is a beta build
1020

1121
A beta build (like this one) will now do version checks against other beta builds and tell you if a newer beta build is available. The link for downloading is also pointing to the beta releases (and not the Media Hoarder website's download section).
1222

1323
![image](https://github.com/theMK2k/Media-Hoarder/assets/16878526/63dadfb6-a7cc-4357-b956-91ee852d0226)
1424

15-
# Older Releases (click to expand)
25+
## Misc (v1.4.0-b5)
26+
27+
- [x] DB Migrations
28+
- [x] new table: tbl_DB_Migrations
29+
- [x] implement migration runner
30+
31+
</details>
1632

1733
<details>
1834
<summary>v1.4.0-b4</summary>

TODO.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
- [ ] cancel loading filters on series -> episodes change
88

9-
- [ ] DB Migrations
10-
11-
- [x] new table: tbl_DB_Migrations
12-
- [ ] implement migration runner
13-
149
- [WIP] introduce HDR (detect with color spaces, e.g. <https://www.reddit.com/r/PleX/comments/7kwoy8/is_there_a_way_to_tell_if_a_file_is_hdr_from_the/>)
1510

1611
- "HDR10", "HDR10+", "DV", "HLG"
@@ -63,9 +58,9 @@
6358
- [ ] rescanHandleDuplicates (also provide snackbar progress for this)
6459
- [ ] investigate with series-generator: find possible multitudes of episode numbers (also: episode == null)
6560
- [ ] if this is the case: we need a better getSeriesEpisodeTconstFromCache, possibly by utilizing levenshtein between filename and imdb's episode title
66-
- #51 Found work around for custom shows and episodes
67-
- #39 Multipart Episodes
68-
- #36 Mediainfo always opening
61+
- [ ] #51 Found work around for custom shows and episodes
62+
- [ ] #39 Multipart Episodes
63+
- [ ] #36 Mediainfo always opening
6964

7065
### Series: Link IMDB Dialog
7166

@@ -93,6 +88,7 @@
9388
- [ ] we apparently do not use the timezone (we store in UTC)
9489
- [ ] scanErrors:
9590
- [ ] review how rescan and applyIMDB handle scanErrors (string to object, handle null)
91+
- [ ] artificially test graphql not found errors
9692
- [ ] introduce WARNING vs. ERROR
9793
- WARNING:
9894
- imdb implausibility

docs/10-Release-Preparation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This document describes the steps necessary to get a new release done.
88
- [ ] Increase Version Number in [../package.json](../package.json)
99
- [ ] create `public/history/version-x.y.z.md` from info in [../DONE.md](../DONE.md)
1010
- [ ] Update history.json (create new entry on top of the others in the array)
11-
- [ ] Test using `npm start` - it should show the new version incl. history
11+
- [ ] Test using `npm run dev[:beta]` - it should show the new version incl. history
1212
- [ ] git push
1313

1414
## Build Packs

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "media-hoarder",
3-
"version": "1.4.0-b5",
3+
"version": "1.4.0-b6",
44
"private": true,
55
"description": "Media Hoarder - THE media frontend for data hoarders and movie lovers",
66
"author": "mk2k <[email protected]> (https://media.hoarder.software)",
@@ -9,6 +9,9 @@
99
"build": "vue-cli-service build",
1010
"lint": "vue-cli-service lint",
1111
"audit": "npm audit --production",
12+
"dev:beta": "check-node-version --node ^14.17 && bash ./apply-monkeypatches.sh && vue invoke electron-builder && npx dotenv-cli -e .env.beta vue-cli-service electron:serve",
13+
"dev:lite": "check-node-version --node ^14.17 && bash ./apply-monkeypatches.sh && vue-cli-service electron:serve",
14+
"dev:stable": "check-node-version --node ^14.17 && bash ./apply-monkeypatches.sh && vue invoke electron-builder && npx dotenv-cli -e .env vue-cli-service electron:serve",
1215
"electron:build": "vue-cli-service electron:build",
1316
"electron:build-linux-portable": "check-node-version --node ^14.17 && bash check-killme.sh && bash check-package.json.sh && bash ./apply-monkeypatches.sh && npx mkdirp RELEASE && node set-portable --portable=true && vue-cli-service electron:build --linux && mv dist_electron/linux-unpacked media-hoarder-portable && npx bestzip RELEASE/media-hoarder-VERSION-linux-x64-portable.zip media-hoarder-portable && npx rimraf media-hoarder-portable && node set-portable --portable=false && node set-release-version.js && rimraf dist_electron",
1417
"electron:build-linux-setup": "check-node-version --node ^14.17 && bash check-killme.sh && bash check-package.json.sh && bash ./apply-monkeypatches.sh && npx mkdirp RELEASE && node set-portable --portable=false && vue-cli-service electron:build --linux deb appimage snap rpm && mv dist_electron/*.deb RELEASE/media-hoarder-VERSION-linux-x64.deb && mv dist_electron/*.AppImage RELEASE/media-hoarder-VERSION-linux-x64.AppImage && mv dist_electron/*.snap RELEASE/media-hoarder-VERSION-linux-x64.snap && mv dist_electron/*.rpm RELEASE/media-hoarder-VERSION-linux-x64.rpm && node set-release-version.js && rimraf dist_electron",
@@ -33,9 +36,6 @@
3336
"postinstall": "electron-builder install-app-deps",
3437
"postuninstall": "electron-builder install-app-deps",
3538
"publish": "vue-cli-service electron:build -p always",
36-
"start": "check-node-version --node ^14.17 && bash ./apply-monkeypatches.sh && vue invoke electron-builder && npx dotenv-cli -e .env vue-cli-service electron:serve",
37-
"start:beta": "check-node-version --node ^14.17 && bash ./apply-monkeypatches.sh && vue invoke electron-builder && npx dotenv-cli -e .env.beta vue-cli-service electron:serve",
38-
"start:lite": "check-node-version --node ^14.17 && bash ./apply-monkeypatches.sh && vue-cli-service electron:serve",
3939
"test": "jest"
4040
},
4141
"main": "background.js",

public/history/history.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"version": "1.4.0-b5",
3+
"version": "1.4.0-b6",
44
"name": "Jean-Luc Picard",
55
"quote": "Make it so.",
66
"quoteSource": "Star Trek: The Next Generation (1987-1994)",

src/find-imdb-tconst.js

+33-13
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,19 @@ export async function findIMDBtconstInNFO(movie) {
7979

8080
/**
8181
* Find an IMDB tconst based on the movie's name (also checks possible release years contained in the name)
82-
* @param {Object} movie
82+
* @param {Object} mediaItem
8383
* @param {Object} options
8484
* @returns {String|Object} with options.returnAnalysisData = true, returns an object with analysis data, else the tconst (or empty string if tconst could't be found)
8585
*/
86-
export async function findIMDBtconstByFileOrDirname(movie, options) {
87-
logger.log("[findIMDBtconstByFileOrDirname] START movie.isDirectoryBased", movie.isDirectoryBased, "movie:", movie);
86+
export async function findIMDBtconstByFileOrDirname(mediaItem, options) {
87+
// TODO: utilize mediaItem.MediaType ("movies" or "series") to rank the IMDB search results
88+
89+
logger.log(
90+
"[findIMDBtconstByFileOrDirname] START mediaItem.isDirectoryBased",
91+
mediaItem.isDirectoryBased,
92+
"mediaItem:",
93+
mediaItem
94+
);
8895

8996
if (!options) {
9097
options = {
@@ -112,18 +119,20 @@ export async function findIMDBtconstByFileOrDirname(movie, options) {
112119
};
113120

114121
try {
115-
logger.log("[findIMDBtconstByFileOrDirname] movie.isDirectoryBased", movie.isDirectoryBased);
116-
const arrYears = movie.isDirectoryBased
122+
logger.log("[findIMDBtconstByFileOrDirname] movie.isDirectoryBased", mediaItem.isDirectoryBased);
123+
const arrYears = mediaItem.isDirectoryBased
117124
? helpers.getYearsFromFileName(
118-
helpers.getLastDirectoryName(movie.MediaType === "series" ? movie.fullPath : movie.fullDirectory),
125+
helpers.getLastDirectoryName(mediaItem.MediaType === "series" ? mediaItem.fullPath : mediaItem.fullDirectory),
119126
false
120127
)
121-
: helpers.getYearsFromFileName(movie.Filename, false);
128+
: helpers.getYearsFromFileName(mediaItem.Filename, false);
122129

123130
const name = (
124-
movie.isDirectoryBased
125-
? helpers.getMovieNameFromDirectory(movie.MediaType === "series" ? movie.fullPath : movie.fullDirectory)
126-
: helpers.getMovieNameFromFileName(movie.Filename)
131+
mediaItem.isDirectoryBased
132+
? helpers.getMovieNameFromDirectory(
133+
mediaItem.MediaType === "series" ? mediaItem.fullPath : mediaItem.fullDirectory
134+
)
135+
: helpers.getMovieNameFromFileName(mediaItem.Filename)
127136
)
128137
.replace(/\([^)]*?\)/g, "")
129138
.replace(/\[[^\]]*?\]/g, "")
@@ -145,6 +154,7 @@ export async function findIMDBtconstByFileOrDirname(movie, options) {
145154
let results = await scrapeIMDBFindPageSearchV3(searchTerm, options.category === "title" ? "tt" : null);
146155

147156
logger.log(`[findIMDBtconstByFileOrDirname] ${results.length} results found for "${searchTerm}"`);
157+
logger.log(`[findIMDBtconstByFileOrDirname] results:`, JSON.parse(JSON.stringify(results)));
148158
stats.numResults = results.length;
149159

150160
if (results.length === 0) {
@@ -174,6 +184,16 @@ export async function findIMDBtconstByFileOrDirname(movie, options) {
174184
}
175185
}
176186

187+
// When scanning a Series source path, re-rank results so that TV Series are preferred
188+
if (mediaItem.MediaType === "series") {
189+
logger.log("[findIMDBtconstByFileOrDirname] re-ranking results according to TV Series");
190+
results = results.sort((a, b) => {
191+
return a.title.includes("(TV Series)") && !b.title.includes("(TV Series)") ? -1 : 0;
192+
});
193+
194+
logger.log("[findIMDBtconstByFileOrDirname] re-ranked results:", results);
195+
}
196+
177197
// filter by year match
178198
if (results.length > 1) {
179199
// losely year match (+/- 1 year allowed)
@@ -205,7 +225,7 @@ export async function findIMDBtconstByFileOrDirname(movie, options) {
205225
}
206226

207227
// filter by runtime, but only use the first 10 items due to traffic
208-
if (results.length > 1 && movie.MI_Duration_Seconds) {
228+
if (results.length > 1 && mediaItem.MI_Duration_Seconds) {
209229
let counter = 0;
210230
for (let result of results) {
211231
counter++;
@@ -219,7 +239,7 @@ export async function findIMDBtconstByFileOrDirname(movie, options) {
219239
if (imdbData.$IMDB_runtimeMinutes) {
220240
const runtimeSeconds = imdbData.$IMDB_runtimeMinutes ? parseInt(imdbData.$IMDB_runtimeMinutes) * 60 : null;
221241

222-
result.runtimeDiff = runtimeSeconds ? Math.abs(movie.MI_Duration_Seconds - runtimeSeconds) : null;
242+
result.runtimeDiff = runtimeSeconds ? Math.abs(mediaItem.MI_Duration_Seconds - runtimeSeconds) : null;
223243

224244
if (result.runtimeDiff !== null) {
225245
stats.runtimematch = true;
@@ -228,7 +248,7 @@ export async function findIMDBtconstByFileOrDirname(movie, options) {
228248
}
229249
}
230250

231-
if (result.runtimeDiff < movie.MI_Duration_Seconds * 0.02) {
251+
if (result.runtimeDiff < mediaItem.MI_Duration_Seconds * 0.02) {
232252
break; // the runtime matches at least to 98%, which is a window of 2 minutes if the movie has a runtime of 100 minutes
233253
}
234254
} else {

0 commit comments

Comments
 (0)