-
Notifications
You must be signed in to change notification settings - Fork 5
Subtitle Selection
In this section I demonstrate a way to sort subtitles based on relevance using weighted keywords.
We want to find subtitles for showname.s01e01.720p.HDTV.x264-acme.
This gets parsed to a TVRelease object that extends the abstract Release object:
| property | value | implementing interface |
|---|---|---|
| show | showname | TVRelease |
| season | 01 | TVRelease |
| episode | 01 | TVRelease |
| tags | Release | |
| 720p | ||
| HDTV | ||
| x264 | ||
| releasegroup | acme | Release |
A MovieRelease object will be available if it matched the criteria.
| property | value | implementing interface |
|---|---|---|
| title | movietitle | MovieRelease |
| year | 01 | MovieRelease |
| tags | Release | |
| 720p | ||
| HDTV | ||
| x264 | ||
| releasegroup | acme | Release |
SubtitleProviders find these subtitles:
| id | Subtitles |
|---|---|
| 1 | showname.s01.e01.720p.bluray.x264-oscorp |
| 2 | showname.s01.e01.hdtv.x264-acme |
| 3 | showname 01x01 this one should work with acme |
| 4 | showname.s01.e01.720p.hdtv.x264-acme |
| 5 | showname.s01.e01.720p.hdtv.x264-releasegroupyouhate |
First up we have to define keywords and assign a weight.
All the keywords can be modified in the settings
| Keyword | Weight |
|---|---|
| %SHOWNAME% | 1 |
| %SEASON% | 1 |
| %EPISODE% | 1 |
| %RELEASEGROUP% | 8 |
These keywords are only used when they are found in the tags of the Release object.
| Keyword | Weight |
|---|---|
| 720p | 2 |
| 1080p | 2 |
| hdtv | 3 |
| bluray | 3 |
| x264 | 2 |
| web-dl | 3 |
| bdrip | 3 |
| 480p | 2 |
These keywords are added by the user.
| Keyword | Weight |
|---|---|
| releasegroupyouhate | -99 |
Based on keywords and weights above the weights-table for showname.s01e01.720p.HDTV.x264-acme would look like this:
| Keyword | Weight |
|---|---|
| showname | 1 |
| s01 | 1 |
| e01 | 1 |
| acme | 8 |
| releasegroupyouhate | -99 |
| 720p | 2 |
| hdtv | 3 |
| x264 | 2 |
A perfect score would be the total of all positive weights. In this case 18
With this table we can calculate the score of every found subtitle. All we have to do is check if the subtitle contains a keyword. If it does, the weight assigned to that keyword gets added to the subtitle's score.
For the found subtitles it would look like this: Note that a placed x means that the subtitle contains the keyword.
| Keyword\SubtitleId | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| showname | x | x | x | x | x |
| s01 | x | x | x | x | x |
| e01 | x | x | x | x | x |
| acme | x | x | x | ||
| releasegroupyouhate | x | ||||
| 720p | x | x | x | ||
| hdtv | x | x | x | ||
| x264 | x | x | x | x | |
| score | 7 | 16 | 11 | 18 | -89 |
The final ordered result is this:
| id | Subtitles | Score | Match (score/maxScore) |
|---|---|---|---|
| 4 | showname.s01.e01.720p.hdtv.x264-acme | 18 | 100% |
| 2 | showname.s01.e01.hdtv.x264-acme | 16 | 88% |
| 3 | showname 01x01 this one should work with acme | 11 | 61% |
| 1 | showname.s01.e01.720p.bluray.x264-oscorp | 7 | 38% |
A slider on the resultpanel could be added to define a threshold. For example to ignore all subtitles with less than 50% match.