Added settings to download only featured subtitles for LegendasTV

This commit is contained in:
dtcabrerizo 2021-07-30 08:34:57 -03:00 committed by GitHub
parent 1d20bbb4b9
commit 33a600a714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 4 deletions

15
.github/scripts/build_test.sh vendored Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
python3 "${ROOT_DIRECTORY}"/bazarr.py &
PID=$!
sleep 30
if kill -s 0 $PID
then
echo "Bazarr is still running. We'll kill it..."
kill $PID
exit 0
else
exit 1
fi

View File

@ -0,0 +1,49 @@
name: test_bazarr_execution
on: workflow_dispatch
jobs:
Test:
runs-on: ubuntu-latest
env:
ROOT_DIRECTORY: .
SCRIPTS_DIRECTORY: .github/scripts
FETCH_DEPTH: 15 # Should be enough
steps:
- name: Validate branch
if: ${{ github.ref != 'refs/heads/development' }}
run: |
echo This action can only be run on development branch, not ${{ github.ref }}
exit 1
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
ref: development
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: "15.x"
- name: Install UI Dependencies
run: npm install
working-directory: ${{ env.UI_DIRECTORY }}
- name: Build UI
run: npm run build
working-directory: ${{ env.UI_DIRECTORY }}
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r '${{ env.ROOT_DIRECTORY }}/requirements.txt'
- name: Test Bazarr execution
run: |
bash '${{ env.SCRIPTS_DIRECTORY }}/build_test.sh'

View File

@ -139,7 +139,8 @@ defaults = {
},
'legendastv': {
'username': '',
'password': ''
'password': '',
'featured_only': 'False'
},
'xsubs': {
'username': '',

View File

@ -164,6 +164,9 @@ def get_providers_auth():
'legendastv' : {
'username': settings.legendastv.username,
'password': settings.legendastv.password,
'featured_only': settings.legendastv.getboolean(
'featured_only'
),
},
'xsubs' : {
'username': settings.xsubs.username,

View File

@ -1,6 +1,6 @@
{
"name": "bazarr",
"version": "1",
"version": "1.0.0",
"description": "Bazarr is a companion application to Sonarr and Radarr. It manages and downloads subtitles based on your requirements. You define your preferences by TV show or movie and Bazarr takes care of everything for you.",
"repository": {
"type": "git",

View File

@ -181,7 +181,9 @@ namespace Settings {
skip_wrong_fps: boolean;
}
interface Legendastv extends BaseProvider {}
interface Legendastv extends BaseProvider {
featured_only: boolean;
}
interface XSubs extends BaseProvider {}

View File

@ -77,6 +77,10 @@ export const ProviderList: Readonly<ProviderInfo[]> = [
defaultKey: {
username: "",
password: "",
featured_only: false,
},
keyNameOverride: {
featured_only: "Only Download Featured",
},
},
{ key: "napiprojekt", description: "Polish Subtitles Provider" },

View File

@ -70,7 +70,7 @@ class LegendasTVProvider(_LegendasTVProvider):
languages = {Language(*l) for l in language_converters['legendastv'].to_legendastv.keys()}
subtitle_class = LegendasTVSubtitle
def __init__(self, username=None, password=None):
def __init__(self, username=None, password=None, featured_only=False):
# Provider needs UNRAR installed. If not available raise ConfigurationError
try:
@ -85,6 +85,7 @@ class LegendasTVProvider(_LegendasTVProvider):
self.password = password
self.logged_in = False
self.session = None
self.featured_only = featured_only
@staticmethod
def is_valid_title(title, title_id, sanitized_title, season, year, imdb_id):
@ -209,6 +210,11 @@ class LegendasTVProvider(_LegendasTVProvider):
# iterate over title's archives
for a in archives:
# Check if featured
if self.featured_only and a.featured == False:
logger.info('Subtitle is not featured, skipping')
continue
# compute an expiration time based on the archive timestamp
expiration_time = (datetime.utcnow().replace(tzinfo=pytz.utc) - a.timestamp).total_seconds()