Skip to content

Commit 8628b34

Browse files
committed
save tv with custom quality profile, rename QualityProfile.quality -> profile, working processors
1 parent f227d7e commit 8628b34

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

src/frontend/src/app/media/media-t-v.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h3 class="media-title">{{ tmdbShow.name }}</h3>
4343
<label class="col-lg-6 col-form-label">Quality Profile</label>
4444
<div class="col-lg-6">
4545
<select class="form-select form-select-sm" [formControl]="qualityProfileControl">
46-
<option *ngFor="let profile of qualityProfiles()" [value]="profile">{{ profile }}</option>
46+
<option *ngFor="let profile of qualityProfiles()" [value]="profile.id">{{ profile.name }}</option>
4747
</select>
4848
</div>
4949
</div>

src/frontend/src/app/media/media-t-v.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export class MediaTVComponent implements OnInit, OnDestroy {
352352
}
353353
}
354354

355-
public qualityProfiles(): string[] {
355+
public qualityProfiles(): any[] {
356356
return this.apiService.qualityProfiles;
357357
}
358358

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.0.2 on 2024-08-01 13:23
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('nefarious', '0084_auto_20240728_1752'),
10+
]
11+
12+
operations = [
13+
migrations.RenameField(
14+
model_name='qualityprofile',
15+
old_name='quality',
16+
new_name='profile',
17+
),
18+
]

src/nefarious/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020

2121
class QualityProfile(models.Model):
2222
name = models.CharField(max_length=500, unique=True)
23-
quality = models.CharField(max_length=500, choices=zip(quality.PROFILE_NAMES, quality.PROFILE_NAMES))
23+
profile = models.CharField(max_length=500, choices=zip(quality.PROFILE_NAMES, quality.PROFILE_NAMES))
2424
min_size_gb = models.DecimalField(
2525
null=True, blank=True, max_digits=10, decimal_places=2, validators=[MinValueValidator(0)], help_text='minimum size (gb) to download')
2626
max_size_gb = models.DecimalField(
2727
null=True, blank=True, max_digits=10, decimal_places=2, validators=[MinValueValidator(0)], help_text='maximum size (gb) to download')
2828

2929
def __str__(self):
30-
if self.name == self.quality:
30+
if self.name == self.profile:
3131
return self.name
32-
return f'{self.name} ({self.quality})'
32+
return f'{self.name} ({self.profile})'
3333

3434

3535
class NefariousSettings(models.Model):

src/nefarious/processors.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from django.utils import dateparse, timezone
77
from transmissionrpc import Torrent
88

9-
from nefarious.models import WatchMovie, NefariousSettings, TorrentBlacklist, WatchTVEpisode, WatchTVSeason
9+
from nefarious.models import WatchMovie, NefariousSettings, TorrentBlacklist, WatchTVEpisode, WatchTVSeason, QualityProfile
1010
from nefarious.parsers.movie import MovieParser
1111
from nefarious.parsers.tv import TVParser
1212
from nefarious.quality import Profile
@@ -61,7 +61,7 @@ def fetch(self):
6161

6262
logger_background.info('Valid Search Results: {}'.format(len(valid_search_results)))
6363

64-
# find the torrent result with the highest weight (i.e seeds)
64+
# find the torrent result with the highest weight (e.g. seeds)
6565
best_result = self._get_best_torrent_result(valid_search_results)
6666

6767
transmission_client = get_transmission_client(self.nefarious_settings)
@@ -99,7 +99,7 @@ def fetch(self):
9999
continue
100100
else:
101101
logger_background.info('No valid search results for {}'.format(self._sanitize_title(str(self.watch_media))))
102-
# try again without possessive apostrophes (ie. The Handmaids Tale vs The Handmaid's Tale)
102+
# try again without possessive apostrophes (e.g. The Handmaids Tale vs The Handmaid's Tale)
103103
if not self._reprocess_without_possessive_apostrophes and self._possessive_apostrophes_regex.search(str(self.watch_media)):
104104
self._reprocess_without_possessive_apostrophes = True
105105
logger_background.warning('Retrying without possessive apostrophes: "{}"'.format(self._sanitize_title(str(self.watch_media))))
@@ -117,7 +117,9 @@ def fetch(self):
117117
def is_match(self, title: str) -> bool:
118118
parser = self._get_parser(title)
119119
quality_profile = self._get_quality_profile()
120-
profile = Profile.get_from_name(quality_profile)
120+
profile = Profile.get_from_name(quality_profile.profile)
121+
122+
# TODO - test other profile attributes (min/max size, HDR, etc)
121123

122124
return (
123125
self._is_match(parser) and
@@ -144,7 +146,7 @@ def _results_with_valid_urls(self, results: list):
144146
def _get_best_torrent_result(self, results: list):
145147
return get_best_torrent_result(results)
146148

147-
def _get_quality_profile(self):
149+
def _get_quality_profile(self) -> QualityProfile:
148150
raise NotImplementedError
149151

150152
def _get_watch_media(self, watch_media_id: int):
@@ -179,7 +181,7 @@ def _get_search_results(self):
179181

180182
class WatchMovieProcessor(WatchProcessorBase):
181183

182-
def _get_quality_profile(self):
184+
def _get_quality_profile(self) -> QualityProfile:
183185
# try custom quality profile then fallback to global setting
184186
return self.watch_media.quality_profile or self.nefarious_settings.quality_profile_movies
185187

@@ -222,7 +224,7 @@ def _get_search_results(self):
222224

223225
class WatchTVProcessorBase(WatchProcessorBase):
224226

225-
def _get_quality_profile(self):
227+
def _get_quality_profile(self) -> QualityProfile:
226228
# try custom quality profile then fallback to global setting
227229
watch_media = self.watch_media # type: WatchTVEpisode|WatchTVSeason
228230
return watch_media.watch_tv_show.quality_profile or self.nefarious_settings.quality_profile_tv

0 commit comments

Comments
 (0)