diff --git a/.github/scripts/build_test.sh b/.github/scripts/build_test.sh new file mode 100644 index 000000000..4e9287fb1 --- /dev/null +++ b/.github/scripts/build_test.sh @@ -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 \ No newline at end of file diff --git a/.github/workflows/test_bazarr_execution.yml b/.github/workflows/test_bazarr_execution.yml new file mode 100644 index 000000000..43aedb859 --- /dev/null +++ b/.github/workflows/test_bazarr_execution.yml @@ -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' diff --git a/bazarr/config.py b/bazarr/config.py index 910497cf5..249204b40 100644 --- a/bazarr/config.py +++ b/bazarr/config.py @@ -139,7 +139,8 @@ defaults = { }, 'legendastv': { 'username': '', - 'password': '' + 'password': '', + 'featured_only': 'False' }, 'xsubs': { 'username': '', diff --git a/bazarr/get_providers.py b/bazarr/get_providers.py index e0fd0293b..497ce4526 100644 --- a/bazarr/get_providers.py +++ b/bazarr/get_providers.py @@ -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, diff --git a/frontend/package.json b/frontend/package.json index f1cb8d833..4cfa61e23 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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", diff --git a/frontend/src/@types/settings.d.ts b/frontend/src/@types/settings.d.ts index bc93bd607..6a6e326d7 100644 --- a/frontend/src/@types/settings.d.ts +++ b/frontend/src/@types/settings.d.ts @@ -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 {} diff --git a/frontend/src/Settings/Providers/list.ts b/frontend/src/Settings/Providers/list.ts index 2d3357687..29d359741 100644 --- a/frontend/src/Settings/Providers/list.ts +++ b/frontend/src/Settings/Providers/list.ts @@ -77,6 +77,10 @@ export const ProviderList: Readonly = [ defaultKey: { username: "", password: "", + featured_only: false, + }, + keyNameOverride: { + featured_only: "Only Download Featured", }, }, { key: "napiprojekt", description: "Polish Subtitles Provider" }, diff --git a/libs/subliminal_patch/providers/legendastv.py b/libs/subliminal_patch/providers/legendastv.py index 97a76a4b1..43db667a7 100644 --- a/libs/subliminal_patch/providers/legendastv.py +++ b/libs/subliminal_patch/providers/legendastv.py @@ -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()