Skip to content

Commit

Permalink
Merge pull request #11099 from pymedusa/release/release-1.0.11
Browse files Browse the repository at this point in the history
Release/release 1.0.11
  • Loading branch information
medariox authored Jan 14, 2023
2 parents 0b9b58d + bd3b612 commit b9292f9
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 10 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.0.11 (14-01-2023)

#### Improvements
- Put showid search results on top
- Change missing directory log level to debug

#### Fixes
- Fix parsing for shows that have year in the title

-----

## 1.0.10 (15-12-2022)

#### Improvements
Expand Down
2 changes: 1 addition & 1 deletion medusa/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
log.logger.addHandler(logging.NullHandler())

INSTANCE_ID = text_type(uuid.uuid1())
VERSION = '1.0.10'
VERSION = '1.0.11'

USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
version=VERSION, system=platform.system(), release=platform.release(),
Expand Down
108 changes: 105 additions & 3 deletions medusa/name_parser/rules/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ def when(self, matches, context):
return [alias]


class FixTitlesThatExistOfNumbers(Rule):
class FixTitlesThatExistOfAbsoluteEpisodeNumbers(Rule):
"""Don't parse titles that exist out of numbers as the 'absolute number'.
'title' - post processor to create titles for show with exlusively numbers in the titel.
'title' - post processor to create titles for show with exlusively numbers in the title.
e.g.: 4400.S01E01.1080p.HEVC.x265-Group.mkv
Expand Down Expand Up @@ -412,6 +412,107 @@ def when(self, matches, context):
return to_remove, to_append


class FixTitlesThatExistOfYearNumbers(Rule):
"""Don't parse titles that exist out of numbers as the 'year'.
'title' - post processor to create titles for show with exlusively numbers in the title.
e.g.: 1923.S01E01.720p.WEB.h264-Group.mkv
guessit -t episode "1923.S01E01.720p.WEB.h264-Group.mkv"
without this rule:
For: 1923.S01E01.720p.WEB.h264-Group.mkv
GuessIt found: {
"year": 1923
"season": 1
"episode": 1
"screen_size": 720p
"video_codec": H.264
"release_group": Group
"type": episode
}
with this rule:
For: 1923.S01E01.720p.WEB.h264-Group.mkv
GuessIt found: {
"title": 1923
"season": 1
"episode": 1
"screen_size": 720p
"video_codec": H.264
"release_group": Group
"type": episode
}
"""

priority = POST_PROCESS
consequence = [RemoveMatch, AppendMatch]

def when(self, matches, context):
"""Evaluate the rule.
:param matches:
:type matches: rebulk.match.Matches
:param context:
:type context: dict
:return:
"""
years = matches.named('year')
if not years:
return

to_remove = []
to_append = []
new_title = None

fileparts = matches.markers.named('path')
for filepart in marker_sorted(fileparts, matches):
old_title = matches.range(filepart.start, filepart.end, predicate=lambda match: match.name == 'title', index=0)
year = matches.range(filepart.start, filepart.end, predicate=lambda match: match.name == 'year', index=0)
episode = matches.range(filepart.start, filepart.end, predicate=lambda match: match.name == 'episode', index=0)

# The parts are evaluated from the files release name to season to show title.
# /1923/Season 01/1923.S01E01.720p.WEB.h264-Group.mkv
# If we already "fixed" the title by getting it from the release name
# Then we don't want to use (or correct) the "year" from the folder name.
if not old_title and new_title and year and str(year.value) == new_title.value:
to_remove.append(year)
continue

if not year or not episode:
continue

# Try to regex the title our selves, when guessit doesn't have any.
fixed_year = None
if not old_title:
match = re.match(r'(\d{4})[. ](\(?\d{4}\)?).*', filepart.value)
if match and len(match.groups()) == 2:
fixed_year = copy.copy(episode)
fixed_year.name = 'title'
fixed_year.value = match.group(1)

if not filepart.value.startswith(str(year.value)) and not fixed_year:
continue

if filepart.value.startswith(str(year.value)):
new_title = copy.copy(year)
new_title.name = 'title'
new_title.value = str(year.value)

to_append.append(new_title)
to_remove.append(year)
if old_title:
to_remove.append(old_title)
continue

if fixed_year:
to_append.append(fixed_year)

return to_remove, to_append


class CreateAliasWithCountryOrYear(Rule):
"""Create alias property using country or year information.
Expand Down Expand Up @@ -1909,7 +2010,8 @@ def rules():
RemoveInvalidEpisodeSeparator,
CreateAliasWithAlternativeTitles,
CreateAliasWithCountryOrYear,
FixTitlesThatExistOfNumbers,
FixTitlesThatExistOfAbsoluteEpisodeNumbers,
FixTitlesThatExistOfYearNumbers,
ReleaseGroupPostProcessor,
FixParentFolderReplacingTitle,
FixMultipleSources,
Expand Down
4 changes: 2 additions & 2 deletions medusa/tv/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ def to_json(self, detailed=True):
def create_meta_files(self):
"""Create episode metadata files."""
if not self.series.is_location_valid():
log.warning('{id}: The series directory is missing, unable to create metadata',
{'id': self.series.series_id})
log.debug('{id}: The series directory is missing, unable to create metadata',
{'id': self.series.series_id})
return

for metadata_provider in itervalues(app.metadata_provider_dict):
Expand Down
59 changes: 59 additions & 0 deletions tests/test_guessit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4575,6 +4575,65 @@
video_profile: 'Advanced Video Codec High Definition'
type: episode


? 1923.S01E01.720p.WEB.h264-Group.mkv
: title: "1923"
season: 1
episode: 1
screen_size: 720p
video_codec: H.264
release_group: Group
container: mkv
source: 'Web'
type: episode

? 1923.2022.S01E01.720p.WEB.h264-Group.mkv
: title: "1923"
season: 1
episode: 1
year: 2022
screen_size: 720p
video_codec: H.264
release_group: Group
container: mkv
source: 'Web'
type: episode

? /1923/Season 01/1923.S01E01.720p.WEB.h264-Group.mkv
: title: "1923"
season: 1
episode: 1
screen_size: 720p
video_codec: H.264
release_group: Group
container: mkv
source: 'Web'
type: episode

? /1923 (2022)/Season 01/1923.S01E01.720p.WEB.h264-Group.mkv
: title: "1923"
season: 1
episode: 1
screen_size: 720p
video_codec: H.264
release_group: Group
container: mkv
source: 'Web'
type: episode

? /1923 (2022)/Season 01/1923.(2022).S01E01.720p.WEB.h264-Group.mkv
: title: "1923"
alias: "1923 2022"
season: 1
episode: 1
year: 2022
screen_size: 720p
video_codec: H.264
release_group: Group
container: mkv
source: 'Web'
type: episode

? /series/9-1-1 (2018)/Season 05/9-1-1 (2018) (S05E06) (2021-11-01) (1080p-h264 BluRay AAC-2ch) Brawl in Cell Block 9-1-1.mkv
: title: '9-1-1'
alias: '9-1-1 2018'
Expand Down
17 changes: 17 additions & 0 deletions themes-default/slim/src/components/new-show-search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
<td>
<app-link :href="result.indexerShowUrl" title="Go to the show's page on the indexer site">
<b>{{ result.showName }}</b>
<span v-if="String(result.showId) === currentSearch.query"
v-tooltip.right="'This is an exact match based on the show id'"
>
*
</span>
</app-link>
</td>
<td class="premiere">{{ result.premiereDate }}</td>
Expand Down Expand Up @@ -142,6 +147,7 @@
import { mapGetters, mapState } from 'vuex';
import { ToggleButton } from 'vue-js-toggle-button';
import { AppLink, LanguageSelect } from './helpers';
import { VTooltip } from 'v-tooltip';
import ExistingShowDialog from './modals/existing-show-dialog.vue';
import axios from 'axios';
Expand All @@ -152,6 +158,9 @@ export default {
ToggleButton,
LanguageSelect
},
directives: {
tooltip: VTooltip
},
props: {
providedInfo: {
default() {
Expand Down Expand Up @@ -235,6 +244,14 @@ export default {
return searchResults.filter(result => result.showName.toLowerCase().includes(nameToSearch.toLowerCase()));
}
// Place results where the showId matches the search query on top.
searchResults.sort((a, _) => {
if (nameToSearch === String(a.showId)) {
return -1;
}
return 1;
});
return searchResults;
},
spinnerSrc() {
Expand Down
2 changes: 1 addition & 1 deletion themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/dark/assets/js/medusa-runtime.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/light/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/light/assets/js/medusa-runtime.js.map

Large diffs are not rendered by default.

0 comments on commit b9292f9

Please sign in to comment.