Skip to content

Commit

Permalink
Merge pull request #4098 from Roardom/fix-tv-range-torrent-group
Browse files Browse the repository at this point in the history
(Fix) Removal of years from tv torrent groups
  • Loading branch information
HDVinnie authored Aug 27, 2024
2 parents 2093d3b + b123761 commit f3c21c8
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions resources/views/components/partials/_torrent-group-row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@ class="torrent-search--grouped__edit"
@case('tv')
{{-- Removes the following patterns from the name: S01, S01E01, S01E01E02, S01E01E02E03, S01E01-E03, 2000-, 2000 --}}
@php
if (
$media->first_air_date !== null &&
preg_match('/^[0-9]{4}/', $media->first_air_date) &&
$media->last_air_date &&
preg_match('/^[0-9]{4}/', $media->last_air_date)
) {
$range = range((int) substr($media->first_air_date, 0, 4) - 1, (int) substr($media->last_air_date, 0, 4) + 1);
if ($media->first_air_date?->year !== null && $media->last_air_date?->year !== null) {
$firstAirDateRange = range($media->first_air_date->year - 1, $media->first_air_date->year + 1);
$fullRange = range($media->first_air_date->year - 1, $media->last_air_date->year + 1);
} else {
$range = [];
$firstAirDateRange = [];
$fullRange = [];
}
@endphp

{{ \preg_replace('/^.*( S\d{2,4}(?:-?E\d{2,4})*? | ' . implode(' | ', range($media->release_date - 1, $media->release_date + 1)) . ' | ' . implode('-| ', $range) . '-)/i', '', $torrent->name) }}
{{ \preg_replace('/^.*( S\d{2,4}(?:-?E\d{2,4})*? | ' . implode(' | ', $firstAirDateRange) . ' | ' . implode('-| ', $fullRange) . '-)/i', '', $torrent->name) }}

@break
@endswitch
Expand Down

0 comments on commit f3c21c8

Please sign in to comment.