diff --git a/.Dockerignore b/.Dockerignore new file mode 100644 index 00000000..588953de --- /dev/null +++ b/.Dockerignore @@ -0,0 +1,8 @@ +# ignore git files +.git* + +# ignore hidden files +.* + +# ignore directories +docs/ diff --git a/.docker_platforms b/.docker_platforms new file mode 100644 index 00000000..38597316 --- /dev/null +++ b/.docker_platforms @@ -0,0 +1 @@ +linux/amd64,linux/arm64/v8,linux/arm/v7 \ No newline at end of file diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..2ea73951 --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +filename = + *.py +max-line-length = 120 +extend-exclude = + venv/ diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..b67ea638 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,38 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" + time: "00:00" + target-branch: "nightly" + open-pull-requests-limit: 10 + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + time: "00:00" + target-branch: "nightly" + open-pull-requests-limit: 10 + + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + time: "00:00" + target-branch: "nightly" + open-pull-requests-limit: 10 + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + time: "00:00" + target-branch: "nightly" + open-pull-requests-limit: 10 diff --git a/.github/label-actions.yml b/.github/label-actions.yml new file mode 100644 index 00000000..29496018 --- /dev/null +++ b/.github/label-actions.yml @@ -0,0 +1,49 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# Configuration for Label Actions - https://github.com/dessant/label-actions + +added: + comment: > + This feature has been added and will be available in the next release. +fixed: + comment: > + This issue has been fixed and will be available in the next release. +invalid:duplicate: + comment: > + :wave: @{issue-author}, this appears to be a duplicate of a pre-existing issue. + close: true + lock: true + unlabel: 'status:awaiting-triage' + +-invalid:duplicate: + reopen: true + unlock: true + +invalid:support: + comment: > + :wave: @{issue-author}, we use the issue tracker exclusively for bug reports. + However, this issue appears to be a support request. Please use our + [Support Center](https://app.lizardbyte.dev/support) for support issues. Thanks. + close: true + lock: true + lock-reason: 'off-topic' + unlabel: 'status:awaiting-triage' + +-invalid:support: + reopen: true + unlock: true + +invalid:template-incomplete: + issues: + comment: > + :wave: @{issue-author}, please edit your issue to complete the template with + all the required info. Your issue will be automatically closed in 5 days if + the template is not completed. Thanks. + prs: + comment: > + :wave: @{issue-author}, please edit your PR to complete the template with + all the required info. Your PR will be automatically closed in 5 days if + the template is not completed. Thanks. diff --git a/.github/pr_release_template.md b/.github/pr_release_template.md new file mode 100644 index 00000000..7c96c6b6 --- /dev/null +++ b/.github/pr_release_template.md @@ -0,0 +1,24 @@ +## Description + +This PR was created automatically. + + +### Screenshot + + + +### Issues Fixed or Closed + + + + + +## Type of Change +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] Documentation update (changes to documentation) +- [ ] Repository update (changes to repository files) + +## Changelog Summary + diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..15bd0d08 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,105 @@ +--- +name: CI + +on: + pull_request: + branches: [master, nightly] + types: [opened, synchronize, reopened] + push: + branches: [master] + workflow_dispatch: + +jobs: + check_changelog: + name: Check Changelog + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Verify Changelog + id: verify_changelog + if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }} + # base_ref for pull request check, ref for push + uses: LizardByte/actions/verify_changelog@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + outputs: + next_version: ${{ steps.verify_changelog.outputs.changelog_parser_version }} + last_version: ${{ steps.verify_changelog.outputs.latest_release_tag_name }} + release_body: ${{ steps.verify_changelog.outputs.changelog_parser_description }} + + build: + runs-on: ubuntu-20.04 + needs: check_changelog + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + path: Themerr-plex.bundle + + - name: Install Python 2.7 + uses: actions/setup-python@v3 + with: + python-version: '2.7' + + - name: Set up Python 2.7 Dependencies + working-directory: Themerr-plex.bundle + run: | + echo "Installing Requirements" + python --version + python -m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip setuptools + + # install dev requirements + python -m pip install --upgrade -r requirements-dev.txt + + # install plugin requirements + python ./scripts/install_requirements.py + + - name: Build plist + working-directory: Themerr-plex.bundle + env: + BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version }} + run: | + python ./scripts/build_plist.py + + - name: Test Plex Plugin + working-directory: Themerr-plex.bundle + run: | + python ./Contents/Code/__init__.py + + - name: Upload Artifacts + if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} + uses: actions/upload-artifact@v3 + with: + name: Themerr-plex.bundle + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + path: | + ${{ github.workspace }} + !**/*.git* + !**/*.pyc + !**/__pycache__ + !**/Themerr-plex.bundle/.* + !**/Themerr-plex.bundle/cache.sqlite + !**/Themerr-plex.bundle/docs + !**/Themerr-plex.bundle/scripts + + - name: Package Release + shell: bash + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + run: | + 7z "-xr!*.git*" "-xr!*.pyc" "-xr!__pycache__" "-x!.*" "-x!cache.sqlite" "-x!docs" "-x!scripts" \ + a "./Themerr-plex.bundle.zip" "Themerr-plex.bundle" + + mkdir artifacts + mv ./Themerr-plex.bundle.zip ./artifacts/ + + - name: Create Release + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + uses: LizardByte/.github/actions/create_release@master + with: + token: ${{ secrets.GH_BOT_TOKEN }} + next_version: ${{ needs.check_changelog.outputs.next_version }} + last_version: ${{ needs.check_changelog.outputs.last_version }} + release_body: ${{ needs.check_changelog.outputs.release_body }} diff --git a/.github/workflows/auto-create-pr.yml b/.github/workflows/auto-create-pr.yml new file mode 100644 index 00000000..ef19e40f --- /dev/null +++ b/.github/workflows/auto-create-pr.yml @@ -0,0 +1,31 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: Auto create PR + +on: + push: + branches: + - 'nightly' + +jobs: + create_pr: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Create Pull Request + uses: repo-sync/pull-request@v2 + with: + source_branch: "" # should be "nightly" as it's the triggering branch + destination_branch: "master" + pr_title: "Pulling ${{ github.ref_name }} into master" + pr_template: ".github/pr_release_template.md" + pr_assignee: "${{ secrets.GH_BOT_NAME }}" + pr_draft: true + pr_allow_empty: false + github_token: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..7ff83e0a --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,59 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: Automerge PR + +on: + pull_request: + types: + - opened + - synchronize + +jobs: + autoapprove: + if: > + contains(fromJson('["LizardByte-bot"]'), github.event.pull_request.user.login) && + contains(fromJson('["LizardByte-bot"]'), github.actor) + runs-on: ubuntu-latest + steps: + - name: Autoapproving + uses: hmarr/auto-approve-action@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Label autoapproved + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['autoapproved', 'autoupdate'] + }) + + automerge: + needs: [autoapprove] + runs-on: ubuntu-latest + concurrency: + group: automerge-${{ github.ref }} + cancel-in-progress: true + + steps: + - name: Automerging + uses: pascalgn/automerge-action@v0.15.3 + env: + BASE_BRANCHES: nightly + GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} + GITHUB_LOGIN: ${{ secrets.GH_BOT_NAME }} + MERGE_LABELS: "" + MERGE_METHOD: "squash" + MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" + MERGE_DELETE_BRANCH: true + MERGE_ERROR_FAIL: true + MERGE_FILTER_AUTHOR: ${{ secrets.GH_BOT_NAME }} + MERGE_RETRIES: "240" # 1 hour + MERGE_RETRY_SLEEP: "15000" # 15 seconds diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml new file mode 100644 index 00000000..f32e65c7 --- /dev/null +++ b/.github/workflows/autoupdate.yml @@ -0,0 +1,32 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# This workflow is designed to work with: +# - automerge workflows + +# It uses GitHub Action that auto-updates pull requests branches, when changes are pushed to their destination branch. +# Auto-updating to the latest destination branch works only in the context of upstream repo and not forks. + +name: autoupdate + +on: + push: + branches: + - 'nightly' + +jobs: + autoupdate-for-bot: + name: Autoupdate autoapproved PR created in the upstream + if: startsWith(github.repository, 'LizardByte/') + runs-on: ubuntu-latest + steps: + - name: Update + uses: docker://chinthakagodawita/autoupdate-action:v1 + env: + GITHUB_TOKEN: '${{ secrets.GH_BOT_TOKEN }}' + PR_FILTER: "labelled" + PR_LABELS: "autoupdate" + PR_READY_STATE: "ready_for_review" + MERGE_CONFLICT_ACTION: "ignore" diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml new file mode 100644 index 00000000..f4a50695 --- /dev/null +++ b/.github/workflows/ci-docker.yml @@ -0,0 +1,192 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: CI Docker + +on: + pull_request: + branches: [master, nightly] + types: [opened, synchronize, reopened] + push: + branches: [master, nightly] + workflow_dispatch: + +jobs: + check_dockerfile: + name: Check Dockerfile + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Check + id: check + run: | + if [ -f "./Dockerfile" ] + then + FOUND=true + else + FOUND=false + fi + + echo "::set-output name=dockerfile::${FOUND}" + + outputs: + dockerfile: ${{ steps.check.outputs.dockerfile }} + + lint_dockerfile: + name: Lint Dockerfile + needs: [check_dockerfile] + if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Lint Dockerfile + uses: actions/checkout@v3 + + - uses: hadolint/hadolint-action@v2.1.0 + with: + dockerfile: ./Dockerfile + + check_changelog: + name: Check Changelog + needs: [check_dockerfile] + if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }} + uses: actions/checkout@v3 + + - name: Verify Changelog + id: verify_changelog + if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }} + # base_ref for pull request check, ref for push + uses: LizardByte/.github/actions/verify_changelog@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + outputs: + next_version: ${{ steps.verify_changelog.outputs.changelog_parser_version }} + + docker: + name: Docker + needs: [check_dockerfile, check_changelog] + if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }} + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Prepare + id: prepare + env: + NEXT_VERSION: ${{ needs.check_changelog.outputs.next_version }} + run: | + # get branch name + BRANCH=${GITHUB_HEAD_REF} + + if [ -z "$BRANCH" ] + then + echo "This is a PUSH event" + BRANCH=${{ github.ref_name }} + fi + + # determine to push image to dockerhub and ghcr or not + if [[ $GITHUB_EVENT_NAME == "push" ]]; then + PUSH=true + else + PUSH=false + fi + + # setup the tags + REPOSITORY=${{ github.repository }} + BASE_TAG=$(echo $REPOSITORY | tr '[:upper:]' '[:lower:]') + COMMIT=${{ github.sha }} + + TAGS="${BASE_TAG}:${COMMIT:0:7},ghcr.io/${BASE_TAG}:${COMMIT:0:7}" + + if [[ $GITHUB_REF == refs/heads/master ]]; then + TAGS="${TAGS},${BASE_TAG}:latest,ghcr.io/${BASE_TAG}:latest" + TAGS="${TAGS},${BASE_TAG}:master,ghcr.io/${BASE_TAG}:master" + elif [[ $GITHUB_REF == refs/heads/nightly ]]; then + TAGS="${TAGS},${BASE_TAG}:nightly,ghcr.io/${BASE_TAG}:nightly" + else + TAGS="${TAGS},${BASE_TAG}:test,ghcr.io/${BASE_TAG}:test" + fi + + if [[ ${NEXT_VERSION} != "" ]]; then + TAGS="${TAGS},${BASE_TAG}:${NEXT_VERSION},ghcr.io/${BASE_TAG}:${NEXT_VERSION}" + fi + + # read the platforms from `.docker_platforms` + PLATFORMS=$(<.docker_platforms) + + echo ::set-output name=branch::${BRANCH} + echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=commit::${COMMIT} + echo ::set-output name=platforms::${PLATFORMS} + echo ::set-output name=push::${PUSH} + echo ::set-output name=tags::${TAGS} + + - name: Set Up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + id: buildx + + - name: Cache Docker Layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Log in to Docker Hub + if: ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Log in to the Container registry + if: ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ secrets.GH_BOT_NAME }} + password: ${{ secrets.GH_BOT_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: ./ + file: ./Dockerfile + push: ${{ steps.prepare.outputs.push }} + platforms: ${{ steps.prepare.outputs.platforms }} + build-args: | + BRANCH=${{ steps.prepare.outputs.branch }} + BUILD_DATE=${{ steps.prepare.outputs.build_date }} + BUILD_VERSION=${{ needs.check_changelog.outputs.next_version }} + COMMIT=${{ steps.prepare.outputs.commit }} + tags: ${{ steps.prepare.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Update Docker Hub Description + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} # token is not currently supported + repository: ${{ env.BASE_TAG }} + short-description: ${{ github.event.repository.description }} + readme-filepath: ./DOCKER_README.md diff --git a/.github/workflows/issues-stale.yml b/.github/workflows/issues-stale.yml new file mode 100644 index 00000000..d6e63e7c --- /dev/null +++ b/.github/workflows/issues-stale.yml @@ -0,0 +1,56 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: Stale Issues / PRs + +on: + schedule: + - cron: '00 00 * * *' + +jobs: + stale: + name: Check Stale Issues / PRs + runs-on: ubuntu-latest + steps: + - name: Stale + uses: actions/stale@v5 + with: + close-issue-message: > + This issue was closed because it has been stalled for 10 days with no activity. + close-pr-message: > + This PR was closed because it has been stalled for 10 days with no activity. + days-before-stale: 90 + days-before-close: 10 + exempt-all-assignees: true + exempt-issue-labels: 'added,fixed' + exempt-pr-labels: 'dependencies,l10n' + stale-issue-label: 'stale' + stale-issue-message: > + This issue is stale because it has been open for 90 days with no activity. + Comment or remove the stale label, otherwise this will be closed in 10 days. + stale-pr-label: 'stale' + stale-pr-message: > + This PR is stale because it has been open for 90 days with no activity. + Comment or remove the stale label, otherwise this will be closed in 10 days. + repo-token: ${{ secrets.GH_BOT_TOKEN }} + + - name: Invalid Template + uses: actions/stale@v5 + with: + close-issue-message: > + This issue was closed because the the template was not completed after 5 days. + close-pr-message: > + This PR was closed because the the template was not completed after 5 days. + days-before-stale: 0 + days-before-close: 5 + exempt-pr-labels: 'dependencies,l10n' + only-labels: 'invalid:template-incomplete' + stale-issue-label: 'invalid:template-incomplete' + stale-issue-message: > + Invalid issues template. + stale-pr-label: 'invalid:template-incomplete' + stale-pr-message: > + Invalid PR template. + repo-token: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml new file mode 100644 index 00000000..6ba44446 --- /dev/null +++ b/.github/workflows/issues.yml @@ -0,0 +1,22 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: Issues + +on: + issues: + types: [labeled, unlabeled] + discussion: + types: [labeled, unlabeled] + +jobs: + label: + name: Label Actions + runs-on: ubuntu-latest + steps: + - name: Label Actions + uses: dessant/label-actions@v2 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml new file mode 100644 index 00000000..0abc26b8 --- /dev/null +++ b/.github/workflows/pull-requests.yml @@ -0,0 +1,27 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: Pull Requests + +on: + pull_request_target: + types: [opened, synchronize, edited, reopened] + +jobs: + check-pull-request: + name: Check Pull Request + runs-on: ubuntu-latest + steps: + - uses: Vankka/pr-target-branch-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + target: master + exclude: nightly # Don't prevent going from nightly -> master + change-to: nightly + comment: | + Your PR was set to `master`, PRs should be sent to `nightly`. + The base branch of this PR has been automatically changed to `nightly`. + Please check that there are no merge conflicts diff --git a/.github/workflows/python-flake8.yml b/.github/workflows/python-flake8.yml new file mode 100644 index 00000000..463fb8a2 --- /dev/null +++ b/.github/workflows/python-flake8.yml @@ -0,0 +1,31 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: flake8 + +on: + pull_request: + branches: [master, nightly] + types: [opened, synchronize, reopened] + +jobs: + flake8: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 # https://github.com/actions/setup-python + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools flake8 + + - name: Test with flake8 + run: | + python -m flake8 --verbose diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml new file mode 100644 index 00000000..f2e07218 --- /dev/null +++ b/.github/workflows/yaml-lint.yml @@ -0,0 +1,46 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: yaml lint + +on: + pull_request: + branches: [master, nightly] + types: [opened, synchronize, reopened] + +jobs: + yaml-lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: yaml lint + id: yaml-lint + uses: ibiqlik/action-yamllint@v3 + with: + # https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration + config_data: | + extends: default + rules: + comments: + level: error + line-length: + max: 120 + truthy: + allowed-values: ['true', 'false', 'on'] # GitHub uses "on" for workflow event triggers + check-keys: true + level: error + + - name: Log + run: | + echo ${{ steps.yaml-lint.outputs.logfile }} + + - name: Upload logs + uses: actions/upload-artifact@v3 + if: failure() + with: + name: yamllint-logfile + path: ${{ steps.yaml-lint.outputs.logfile }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..98bcd02d --- /dev/null +++ b/.gitignore @@ -0,0 +1,173 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + +# Remove the agent Info.plist since we are building it +Contents/Info.plist + +# Remove plexhints files +plexhints-temp +*cache.sqlite + +# Remove python modules +Contents/Libraries/Shared/* + +# Keep requirements.txt files +!*requirements.txt diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 00000000..086d61fb --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,28 @@ +--- +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the version of Python +build: + os: ubuntu-20.04 + tools: + python: "2.7" + +# Build documentation in the docs/ directory with Sphinx +sphinx: + builder: html + configuration: docs/source/conf.py + fail_on_warning: true + +# Using Sphinx, build docs in additional formats +formats: all + +python: + install: + - requirements: requirements.txt # plugin requirements + - requirements: requirements-dev.txt # docs requirements + system_packages: true diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py new file mode 100644 index 00000000..66d79fb8 --- /dev/null +++ b/Contents/Code/__init__.py @@ -0,0 +1,354 @@ +# -*- coding: utf-8 -*- + +# standard imports +import re +import sys + +# plex debugging +if 'plexscripthost' not in sys.executable.lower(): # the code is running outside of Plex + from plexhints import plexhints_setup, update_sys_path + plexhints_setup() # read the plugin plist file and determine if plexhints should use elevated policy or not + update_sys_path() # when running outside plex, append the path + + from plexhints.agent_kit import Agent, Media # agent kit + from plexhints.decorator_kit import handler # decorator kit + from plexhints.locale_kit import Locale + from plexhints.log_kit import Log # log kit + from plexhints.model_kit import Movie # model kit + from plexhints.object_kit import MessageContainer, MetadataSearchResult, SearchResult # object kit + from plexhints.parse_kit import JSON # parse kit + from plexhints.prefs_kit import Prefs # prefs kit + +# imports from Libraries\Shared +from typing import Optional +import youtube_dl + +# local imports +if sys.version_info.major < 3: + from default_prefs import default_prefs + from plex_api_helper import add_themes +else: + from .default_prefs import default_prefs + from .plex_api_helper import add_themes + + +def process_youtube(url): + # type: (str) -> Optional[str] + """ + Process URL using `youtube_dl` + + Parameters + ---------- + url : str + The URL of the YouTube video. + + Returns + ------- + Optional[str] + The URL of the audio object. + + Examples + -------- + >>> process_youtube(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ') + ... + """ + youtube_dl_params = dict( + outmpl='%(id)s.%(ext)s', + youtube_include_dash_manifest=False, + username=Prefs['str_youtube_user'] if Prefs['str_youtube_user'] else None, + password=Prefs['str_youtube_passwd'] if Prefs['str_youtube_passwd'] else None, + ) + + ydl = youtube_dl.YoutubeDL(params=youtube_dl_params) + + with ydl: + result = ydl.extract_info( + url=url, + download=False # We just want to extract the info + ) + if 'entries' in result: + # Can be a playlist or a list of videos + video_data = result['entries'][0] + else: + # Just a video + video_data = result + + size = 0 + audio_url = None + if video_data: + for fmt in video_data['formats']: # loop through formats, select largest audio size for better quality + if 'audio only' in fmt['format']: + filesize = int(fmt['filesize']) + if filesize > size: + size = filesize + audio_url = fmt['url'] + + return audio_url # return None or url found + + +def ValidatePrefs(): + # type: () -> MessageContainer + """ + Validate plug-in preferences. + + This function is called when the user modifies their preferences. The developer can check the newly provided values + to ensure they are correct (e.g. attempting a login to validate a username and password), and optionally return a + ``MessageContainer`` to display any error information to the user. See the archived Plex documentation + `Predefined functions + `_ + for more information. + + Returns + ------- + MessageContainer + Success or Error message dependeing on results of validation. + + Examples + -------- + >>> ValidatePrefs() + ... + """ + # todo - validate username and password + error_message = '' # start with a blank error message + + for key in default_prefs: + try: + Prefs[key] + except KeyError: + Log.Critical("Setting '%s' missing from 'DefaultPrefs.json'" % key) + error_message += "Setting '%s' missing from 'DefaultPrefs.json'
" % key + else: + # test all types except 'str_' as string cannot fail + if key.startswith('int_'): + try: + int(Prefs[key]) + except ValueError: + Log.Error("Setting '%s' must be an integer; Value '%s'" % (key, Prefs[key])) + error_message += "Setting '%s' must be an integer; Value '%s'
" % (key, Prefs[key]) + elif key.startswith('bool_'): + if Prefs[key] is not True and Prefs[key] is not False: + Log.Error("Setting '%s' must be True or False; Value '%s'" % (key, Prefs[key])) + error_message += "Setting '%s' must be True or False; Value '%s'
" % (key, Prefs[key]) + + if error_message != '': + return MessageContainer(header='Error', message=error_message) + else: + Log.Info("DefaultPrefs.json is valid") + return MessageContainer(header='Success', message='RetroArcher - Provided preference values are ok') + + +def Start(): + # type: () -> None + """ + Start the plug-in. + + This function is called when the plug-in first starts. It can be used to perform extra initialisation tasks such as + configuring the environment and setting default attributes. See the archived Plex documentation + `Predefined functions + `_ + for more information. + + Examples + -------- + >>> Start() + ... + """ + # validate prefs + prefs_valid = ValidatePrefs() + if prefs_valid.header == 'Error': + Log.Warn('Themerr-plex plug-in preferences are not valid.') + + Log.Debug('Themerr-plex plug-in started.') + + +@handler(prefix='/video/themerr-plex', name='Themerr-plex', thumb='attribution.png') +def main(): + """ + Create the main plug-in ``handler``. + + This is responsible for displaying the plug-in in the plug-ins menu. Since we are using the ``@handler`` decorator, + and since Plex removed menu's from plug-ins, this method does not need to perform any other function. + """ + pass + + +class Themerr(Agent.Movies): + """ + Class representing the Themerr-plex Movie Agent. + + This class defines the metadata agent. See the archived Plex documentation + `Defining an agent class + `_ + for more information. + + References + ---------- + name : str + A string defining the name of the agent for display in the GUI. + languages : list + A list of strings defining the languages supported by the agent. These values should be taken from the constants + defined in the `Locale + `_ + API. + primary_provider : bool + A boolean value defining whether the agent is a primary metadata provider or not. Primary providers can be + selected as the main source of metadata for a particular media type. If an agent is secondary + (``primary_provider`` is set to ``False``) it will only be able to contribute to data provided by another + primary agent. + fallback_agent : Optional[str] + A string containing the identifier of another agent to use as a fallback. If none of the matches returned by an + agent are a close enough match to the given set of hints, this fallback agent will be called to attempt to find + a better match. + accepts_from : Optional[list] + A list of strings containing the identifiers of agents that can contribute secondary data to primary data + provided by this agent. + contributes_to : Optional[list] + A list of strings containing the identifiers of primary agents that the agent can contribute secondary data to. + + Methods + ------- + search: + Search for an item. + update: + Add or update metadata for an item. + + Examples + -------- + >>> Themerr() + ... + """ + name = 'Themerr-plex' + languages = [ + Locale.Language.English + ] + primary_provider = False + fallback_agent = False + accepts_from = [] + contributes_to = [ + 'com.plexapp.agents.imdb', + 'com.plexapp.agents.themoviedb', + # 'com.plexapp.agents.thetvdb', # not available as movie agent + 'dev.lizardbyte.retroarcher-plex' + ] + + @staticmethod + def search(results, media, lang, manual): + # type: (SearchResult, Media.Movie, str, bool) -> Optional[SearchResult] + """ + Search for an item. + + When the media server needs an agent to perform a search, it calls the agent’s ``search`` method. See the + archived Plex documentation + `Searching for results to provide matches for media + `_ + for more information. + + Parameters + ---------- + results : SearchResult + An empty container that the developer should populate with potential matches. + media : Media.Movie + An object containing hints to be used when performing the search. + lang : str + A string identifying the user’s currently selected language. This will be one of the constants added to the + agent’s ``languages`` attribute. + manual : bool + A boolean value identifying whether the search was issued automatically during scanning, or manually by the + user (in order to fix an incorrect match). + + Returns + ------- + Optional[SearchResult] + The search result object, if the search was successful. + + Examples + -------- + >>> Themerr().search(results=..., media=..., lang='en', manual=True) + ... + """ + Log.Debug('Searching with arguments: {results=%s, media=%s, lang=%s, manual=%s' % + (results, media, lang, manual)) + + if media.primary_metadata is None or media.primary_agent is None: + Log.Error('Search is being called in a primary agent.') + return + + Log.Debug('Primary agent: %s' % media.primary_agent) + Log.Debug('media.primary_metadata.id: %s' % media.primary_metadata.id) + + # the media_id will be used to create the url path, replacing `-` with `/` + if media.primary_metadata == 'dev.lizardbyte.retroarcher-plex': + media_id = 'games-%s' % re.search(r'((igdb)-(\d+))', media.primary_metadata.id).group(1) + else: + media_id = 'movies-%s-%s' % (media.primary_agent.rsplit('.', 1)[-1], media.primary_metadata.id) + # e.g. = 'movies-imdb-tt0113189' + # e.g. = 'movies-themoviedb-710' + + results.Append(MetadataSearchResult( + id=media_id, + name=media.primary_metadata.title, + year=media.primary_metadata.year, + score=100, + lang=lang, # no lang to get from db + thumb=None # no point in adding thumb since plex won't show it anywhere + )) + + # sort the results first by year, then by score + results.Sort(attr='year') + results.Sort(attr='score', descending=True) + return results + + @staticmethod + def update(metadata, media, lang, force): + # type: (Movie, Media.Movie, str, bool) -> Optional[Movie] + """ + Update metadata for an item. + + Once an item has been successfully matched, it is added to the update queue. As the framework processes queued + items, it calls the ``update`` method of the relevant agents. See the archived Plex documentation + `Adding metadata to media + `_ + for more information. + + Parameters + ---------- + metadata : object + A pre-initialized metadata object if this is the first time the item is being updated, or the existing + metadata object if the item is being refreshed. + media : object + An object containing information about the media hierarchy in the database. + lang : str + A string identifying which language should be used for the metadata. This will be one of the constants + defined in the agent’s ``languages`` attribute. + force : bool + A boolean value identifying whether the user forced a full refresh of the metadata. If this argument is + ``True``, all metadata should be refreshed, regardless of whether it has been populated previously. + + Examples + -------- + >>> Themerr().update(metadata=..., media=..., lang='en', force=True) + ... + """ + Log.Debug('Updating with arguments: {metadata=%s, media=%s, lang=%s, force=%s' % + (metadata, media, lang, force)) + + rating_key = int(media.id) # rating key of plex item + Log.Info('Rating key: %s' % rating_key) + + Log.Info('metadata.id: %s' % metadata.id) + url = 'https://app.lizardbyte.dev/ThemerrDB/%s.json' % metadata.id.replace('-', '/') + + data = JSON.ObjectFromURL(url=url, errors='ignore') + + try: + yt_video_url = data['youtube_theme_url'] + except KeyError: + Log.Info('No theme song found for %s (%s)' % (metadata.title, metadata.year)) + return + else: + theme_url = process_youtube(url=yt_video_url) + + if theme_url: + add_themes(rating_key=rating_key, theme_urls=[theme_url]) + + return metadata diff --git a/Contents/Code/default_prefs.py b/Contents/Code/default_prefs.py new file mode 100644 index 00000000..2dfb8449 --- /dev/null +++ b/Contents/Code/default_prefs.py @@ -0,0 +1,6 @@ +default_prefs = dict( + int_upload_timeout='60', + str_youtube_user='', + str_youtube_passwd='', + url_plex_server='http://localhost:32400' +) diff --git a/Contents/Code/plex_api_helper.py b/Contents/Code/plex_api_helper.py new file mode 100644 index 00000000..1babbbef --- /dev/null +++ b/Contents/Code/plex_api_helper.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- + +# standard imports +import sys + +# plex debugging +if 'plexscripthost' not in sys.executable.lower(): # the code is running outside of Plex + from plexhints.log_kit import Log + from plexhints.prefs_kit import Prefs + +# imports from Libraries\Shared +import requests +from typing import Optional +import urllib3 +import plexapi +from plexapi.server import PlexServer + + +def setup_plexapi(): + """ + Create the Plex server object. + + It is required to use PlexAPI in order to add theme music to movies, as the built-in methods for metadata agents + do not work for movies. This method creates the server object. + + Returns + ------- + PlexServer + The PlexServer object. + + Examples + -------- + >>> setup_plexapi() + ... + """ + plexapi.TIMEOUT = int(Prefs['int_upload_timeout']) + + plex_url = Prefs['url_plex_server'] + Log.Debug('Plex url: %s' % plex_url) + + plex_token = Prefs['str_plex_token'] + + if not plex_token: + Log.Error('Plex token not set in agent settings, cannot proceed.') + return False + + sess = requests.Session() + sess.verify = False # Ignore verifying the SSL certificate + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Disable the insecure request warning + + # create the plex server object + plex = PlexServer(baseurl=plex_url, token=plex_token, session=sess) + + return plex + + +def add_themes(rating_key, theme_files=None, theme_urls=None): + # type: (int, Optional[list], Optional[list]) -> None + """ + Apply themes to the specified item. + + Adds theme songs to the item specified by the ``rating_key``. + + Parameters + ---------- + rating_key : str + The key corresponding to the item that the themes will be added to. + theme_files : Optional[list] + A list of paths to theme songs. + theme_urls : Optional[list] + A list of urls to theme songs. + + Examples + -------- + >>> add_themes(theme_list=[...], rating_key=...) + """ + if theme_files or theme_urls: + plex = setup_plexapi() + + Log.Info('Plexapi working with item with rating key: %s' % rating_key) + + if plex: + plex_item = plex.fetchItem(ekey=int(rating_key)) # must be an int or weird things happen + + if theme_files: + for theme_file in theme_files: + Log.Info('Attempting to upload theme file: %s' % theme_file) + plex_item.uploadTheme(filepath=theme_file) + if theme_urls: + for theme_url in theme_urls: + Log.Info('Attempting to upload theme file: %s' % theme_url) + plex_item.uploadTheme(url=theme_url) + else: + Log.Info('No theme songs provided for rating key: %s' % rating_key) diff --git a/Contents/DefaultPrefs.json b/Contents/DefaultPrefs.json new file mode 100644 index 00000000..b4f8c34e --- /dev/null +++ b/Contents/DefaultPrefs.json @@ -0,0 +1,39 @@ +[ + { + "id": "int_upload_timeout", + "type": "text", + "label": "Upload Timeout (in seconds)", + "default": "60", + "secure": "false" + }, + { + "id": "str_youtube_user", + "type": "text", + "label": "YouTube Username", + "default": "", + "secure": "true" + }, + { + "id": "str_youtube_passwd", + "type": "text", + "label": "YouTube Password", + "default": "", + "option": "hidden", + "secure": "true" + }, + { + "id": "url_plex_server", + "type": "text", + "label": "Plex Server URL", + "default": "http://localhost:32400", + "secure": "true" + }, + { + "id": "str_plex_token", + "type": "text", + "label": "Plex token", + "default": "", + "option": "hidden", + "secure": "true" + } +] diff --git a/Contents/Libraries/Shared/requirements.txt b/Contents/Libraries/Shared/requirements.txt new file mode 100644 index 00000000..6a663c89 --- /dev/null +++ b/Contents/Libraries/Shared/requirements.txt @@ -0,0 +1,9 @@ +# these requirements must support python 2.7 +# it is doubtful that Plex will ever update to Python 3+ +requests==2.27.1;python_version<"3" # 2.27 is last version supporting Python 2.7 +typing==3.10.0.0 +youtube_dl==2021.12.17 + +# custom python-plexapi supporting python 2.7 +# this is used to upload theme songs since Movie agents cannot correctly do so +git+https://github.com/reenignearcher/python-plexapi.git@master-py2.7#egg=plexapi diff --git a/Contents/Resources/attribution.png b/Contents/Resources/attribution.png new file mode 100644 index 00000000..88e40eb3 Binary files /dev/null and b/Contents/Resources/attribution.png differ diff --git a/Contents/Resources/icon-default.png b/Contents/Resources/icon-default.png new file mode 100644 index 00000000..162dee10 Binary files /dev/null and b/Contents/Resources/icon-default.png differ diff --git a/DOCKER_README.md b/DOCKER_README.md new file mode 100644 index 00000000..f47a3c1b --- /dev/null +++ b/DOCKER_README.md @@ -0,0 +1,28 @@ +### lizardbyte/themerr-plex + +This is a [docker-mod](https://linuxserver.github.io/docker-mods/) for +[plex](https://hub.docker.com/r/linuxserver/plex) which adds [Themerr-plex](https://github.com/LizardByte/Themerr-plex) +to plex as a plugin, to be downloaded/updated during container start. + +This image extends the plex image, and is not intended to be created as a separate container. + +### Installation + +In plex docker arguments, set an environment variable `DOCKER_MODS=lizardbyte/themerr-plex:latest` or +`DOCKER_MODS=ghcr.io/lizardbyte/themerr-plex:latest` + +If adding multiple mods, enter them in an array separated by `|`, such as +`DOCKER_MODS=lizardbyte/themerr-plex:latest|linuxserver/mods:other-plex-mod` + +### Supported Architectures + +Specifying `lizardbyte/themerr-plex:latest` or `ghcr.io/lizardbyte/themerr-plex:latest` should retrieve the correct +image for your architecture. + +The architectures supported by this image are: + +| Architecture | Available | +|:------------:|:---------:| +| x86-64 | ✅ | +| arm64 | ✅ | +| armhf | ✅ | diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3a10bd56 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# buildstage +FROM python:2.7.18-alpine3.11 as buildstage + +# build args +ARG BUILD_VERSION +ARG COMMIT +ARG GITHUB_SHA=$COMMIT +# note: BUILD_VERSION may be blank, COMMIT is also available +# note: build_plist.py uses BUILD_VERSION and GITHUB_SHA + +# setup build directory +RUN mkdir /build +WORKDIR /build/ + +# copy repo +COPY . . + +RUN python # update pip \ + -m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip==20.3.4 setuptools \ + && python -m pip install --upgrade -r requirements-dev.txt # install dev requirements \ + && python ./scripts/install_requirements.py # install plugin requirements \ + && python ./scripts/build_plist.py # build plist \ + && rm -r ./scripts/ # remove scripts dir + +# single layer deployed image +FROM scratch + +# variables +ARG PLUGIN_NAME="Themerr-plex.bundle" +ARG PLUGIN_DIR="/config/Library/Application Support/Plex Media Server/Plug-ins" + +# add files from buildstage +COPY --from=buildstage /build/ $PLUGIN_DIR/$PLUGIN_NAME diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..0ad25db4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..ee85c894 --- /dev/null +++ b/README.rst @@ -0,0 +1,40 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/README.rst + +Overview +======== +LizardByte has the full documentation hosted on `Read the Docs `_. + +About +----- +Themerr-plex is a metadata agent plug-in for Plex Media Player. The plug-in adds theme music to your movies. + +This plugin contributes to the following metadata agents. + + - `com.plexapp.agents.imdb` + - `com.plexapp.agents.themoviedb` + - `dev.lizardbyte.retroarcher-plex` + +Themerr-plex cannot contribute to the new movie agents. In the future we may add a workaround for dealing with movie +libraries that use the new agents. + +Integrations +------------ + +.. image:: https://img.shields.io/github/workflow/status/lizardbyte/themerr-plex/CI/master?label=CI%20build&logo=github&style=for-the-badge + :alt: GitHub Workflow Status (CI) + :target: https://github.com/LizardByte/Themerr-plex/actions/workflows/CI.yml?query=branch%3Amaster + +.. image:: https://img.shields.io/readthedocs/themerr-plex?label=Docs&style=for-the-badge&logo=readthedocs + :alt: Read the Docs + :target: http://themerr-plex.readthedocs.io/ + +Downloads +--------- + +.. image:: https://img.shields.io/github/downloads/lizardbyte/themerr-plex/total?style=for-the-badge&logo=github + :alt: GitHub Releases + :target: https://github.com/LizardByte/Themerr-plex/releases/latest + +.. image:: https://img.shields.io/docker/pulls/lizardbyte/themerr-plex?style=for-the-badge&logo=docker + :alt: Docker + :target: https://hub.docker.com/r/lizardbyte/themerr-plex diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..d0c3cbf1 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..dc1312ab --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/about/docker.rst b/docs/source/about/docker.rst new file mode 100644 index 00000000..1c0682d8 --- /dev/null +++ b/docs/source/about/docker.rst @@ -0,0 +1,6 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/DOCKER_README.md + +Docker +------ + +.. mdinclude:: ../../../DOCKER_README.md diff --git a/docs/source/about/installation.rst b/docs/source/about/installation.rst new file mode 100644 index 00000000..29aff326 --- /dev/null +++ b/docs/source/about/installation.rst @@ -0,0 +1,33 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/about/installation.rst + +Installation +============ +The recommended method for running Themerr-plex is to use the `bundle`_ in the `latest release`_. + +Bundle +------ +The bundle is cross platform, meaning Linux, macOS, and Windows are supported. + +#. Download the ``themerr-plex.bundle.zip`` from the `latest release`_ +#. Extract the contents to your Plex Media Server Plugins directory. + +.. Tip:: See + `How do I find the Plug-Ins folder `_ + for information specific to your Plex server install. + +Docker +------ +Docker images are available on `Dockerhub`_ and `ghcr.io`_. + +See :ref:`Docker ` for additional information. + +Source +------ +.. Caution:: Installing from source is not recommended most users. + +#. Follow the steps in :ref:`Build `. +#. Move the compiled ``themerr-plex.bundle`` to your Plex Media Server Plugins directory. + +.. _latest release: https://github.com/LizardByte/Themerr-plex/releases/latest +.. _Dockerhub: https://hub.docker.com/repository/docker/lizardbyte/themerr-plex +.. _ghcr.io: https://github.com/orgs/LizardByte/packages?repo_name=themerr-plex diff --git a/docs/source/about/overview.rst b/docs/source/about/overview.rst new file mode 100644 index 00000000..ec7f5245 --- /dev/null +++ b/docs/source/about/overview.rst @@ -0,0 +1 @@ +.. include:: ../../../README.rst \ No newline at end of file diff --git a/docs/source/about/usage.rst b/docs/source/about/usage.rst new file mode 100644 index 00000000..14d5dffe --- /dev/null +++ b/docs/source/about/usage.rst @@ -0,0 +1,67 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/about/usage.rst + +Usage +===== + +Minimal setup is required to use Themerr-plex. In addition to the installation, a couple of settings must be configured. + + #. Navigate to the `Plugins` menu within the Plex server settings. + #. Select the gear cog when hovering over the Themerr-plex plugin tile. + #. Set the values of the preferences and save. + #. Enable `Themerr-plex` in your agent settings. + +.. Attention:: You must re-match your movies in order for `Themerr-plex` to apply themes to them. This is a + limitation with Plex. + +Preferences +----------- + +Upload Timeout +^^^^^^^^^^^^^^ + +Description + The timeout (in seconds) when uploading theme audio to the Plex server. + +Default + ``60`` + +YouTube Username +^^^^^^^^^^^^^^^^ + +Description + The YouTube Username to use. Supplying YouTube credentials will allow access to age restricted content. + +Default + None + +YouTube Password +^^^^^^^^^^^^^^^^ + +Description + The YouTube Password to use. Supplying YouTube credentials will allow access to age restricted content. + +Default + None + +Plex Server URL +^^^^^^^^^^^^^^^ + +Description + The URL to use for accessing the Plex server. Themerr-plex uses `python-plexapi` to upload theme songs, so must have + access to the Plex URL. + +Default + ``http://localhost:32400`` + +Plex token +^^^^^^^^^^ + +Description + The token to use for accessing the Plex server. Themerr-plex uses `python-plexapi` to upload theme songs, so this + must be set. + + .. Tip:: See `Finding an authentication token / X-Plex-Token + `_. + +Default + None diff --git a/docs/source/code_docs/main.rst b/docs/source/code_docs/main.rst new file mode 100644 index 00000000..72724119 --- /dev/null +++ b/docs/source/code_docs/main.rst @@ -0,0 +1,9 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/Contents/Code/__init__.py + +.. include:: ../global.rst + +:modname:`__init__` +------------------------ +.. automodule:: Code + :members: + :show-inheritance: diff --git a/docs/source/code_docs/plex_api_helper.rst b/docs/source/code_docs/plex_api_helper.rst new file mode 100644 index 00000000..870cddca --- /dev/null +++ b/docs/source/code_docs/plex_api_helper.rst @@ -0,0 +1,9 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/Contents/Code/plex_api_helper.py + +.. include:: ../global.rst + +:modname:`plex_api_helper` +-------------------------- +.. automodule:: Code.plex_api_helper + :members: + :show-inheritance: diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 00000000..4ae73f59 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,107 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# standard imports +from datetime import datetime +import os +import re +import sys + + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. + +script_dir = os.path.dirname(os.path.abspath(__file__)) # the directory of this file +source_dir = os.path.dirname(script_dir) # the source folder directory +root_dir = os.path.dirname(source_dir) # the root folder directory + + +paths = [ + os.path.join(root_dir, 'Contents', 'Libraries', 'Shared'), # location of plugin dependencies + os.path.join(root_dir, 'Contents'), # location of "Code" module, aka the Plugin +] + +for directory in paths: + sys.path.insert(0, directory) + +# -- Project information ----------------------------------------------------- +project = 'Themerr-plex' +copyright = '%s, %s' % (datetime.now().year, project) +author = 'ReenigneArcher' + +# The full version, including alpha/beta/rc tags +with open(os.path.join(root_dir, 'CHANGELOG.md'), 'r') as f: + version = re.search(r"\[((\d+)\.(\d+)\.(\d+))]", str(f.read())).group(1) + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'm2r2', # enable markdown files + 'numpydoc', # this automatically loads `sphinx.ext.autosummary` as well + 'sphinx.ext.autodoc', # autodocument modules + 'sphinx.ext.autosectionlabel', + 'sphinx.ext.todo', # enable to-do sections + 'sphinx.ext.viewcode' # add links to view source code +] + +# Add any paths that contain templates here, relative to this directory. +# templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ['toc.rst'] + +# Extensions to include. +source_suffix = ['.rst', '.md'] + +# Change default contents file +master_doc = 'index' + +# -- Options for HTML output ------------------------------------------------- + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +# html_static_path = ['_static'] + +html_logo = os.path.join(root_dir, 'Contents', 'Resources', 'attribution.png') + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'sphinx_rtd_theme' + +html_theme_options = { + 'analytics_id': 'G-SSW90X5YZX', # Provided by Google in your dashboard + 'analytics_anonymize_ip': False, + 'logo_only': False, + 'display_version': True, + 'prev_next_buttons_location': 'bottom', + 'style_external_links': True, + 'vcs_pageview_mode': 'blob', + 'style_nav_header_background': '#151515', + # Toc options + 'collapse_navigation': True, + 'sticky_navigation': True, + 'navigation_depth': 4, + 'includehidden': True, + 'titles_only': False, +} + +# extension config options +autodoc_preserve_defaults = True # Do not evaluate default arguments of functions +autosectionlabel_prefix_document = True # Make sure the target is unique +todo_include_todos = True + +# numpydoc config +numpydoc_validation_checks = {'all', 'SA01'} # Report warnings for all checks *except* for SA01 diff --git a/docs/source/contributing/build.rst b/docs/source/contributing/build.rst new file mode 100644 index 00000000..0b2138f8 --- /dev/null +++ b/docs/source/contributing/build.rst @@ -0,0 +1,49 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/contributing/build.rst + +Build +===== +Compiling Themerr-plex is fairly simple; however it is recommended to use Python 2.7 since the Plex framework is using +Python 2.7. + +Clone +----- +Ensure `git `_ is installed and run the following: + + .. code-block:: bash + + git clone https://github.com/lizardbyte/themerr-plex.git themerr-plex.bundle + cd ./themerr-plex.bundle + +Setup venv +---------- +It is recommended to setup and activate a `venv`_. + +Install Requirements +-------------------- +Install Requirements + .. code-block:: bash + + # use python 2.7 venv + python ./scripts/install_requirements.txt + +Development Requirements + .. code-block:: bash + + python -m pip install -r ./scripts/requirements-dev.txt + +Build Plist +----------- + .. code-block:: bash + + python ./scripts/build_plist.py + +Remote Build +------------ +It may be beneficial to build remotely in some cases. This will enable easier building on different operating systems. + +#. Fork the project +#. Activate workflows +#. Trigger the `CI` workflow manually +#. Download the artifacts from the workflow run summary + +.. _venv: https://docs.python.org/3/library/venv.html diff --git a/docs/source/contributing/database.rst b/docs/source/contributing/database.rst new file mode 100644 index 00000000..21a299f6 --- /dev/null +++ b/docs/source/contributing/database.rst @@ -0,0 +1,7 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/contributing/database.rst + +Database +======== + +The database of themes is held in our `ThemerrDB `_ repository. To contribute +to the database, follow the documentation there. diff --git a/docs/source/contributing/testing.rst b/docs/source/contributing/testing.rst new file mode 100644 index 00000000..4bbe28ba --- /dev/null +++ b/docs/source/contributing/testing.rst @@ -0,0 +1,54 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/contributing/testing.rst + +Testing +======= + +Flake8 +------ +Themerr-plex uses `Flake8 `_ for enforcing consistent code styling. Flake is included +in the ``requirements-dev.txt``. + +The config file for flake8 is ``.flake8``. This is already included in the root of the repo and should not be modified. + +Test with Flake8 + .. code-block:: bash + + python -m flake8 + +Sphinx +------ +Themerr-plex uses `Sphinx `_ for documentation building. Sphinx is included +in the ``requirements-dev.txt``. + +Themerr-plex follows `numpydoc `_ styling and formatting in +docstrings. This will be tested when building the docs. `numpydoc` is included in the ``requirements-dev.txt``. + +The config file for Sphinx is ``docs/source/conf.py``. This is already included in the root of the repo and should not +be modified. + +Test with Sphinx + .. code-block:: bash + + cd docs + make html + + Alternatively + + .. code-block:: bash + + cd docs + sphinx-build -b html source build + +pytest +------ +.. Todo:: PyTest is not yet implemented. + +Themerr-plex uses `pytest `_ for unit testing. pytest is included in the +``requirements-dev.txt``. + +No config is required for pytest. + +Test with pytest + .. code-block:: bash + + python -m pytest diff --git a/docs/source/global.rst b/docs/source/global.rst new file mode 100644 index 00000000..b1170045 --- /dev/null +++ b/docs/source/global.rst @@ -0,0 +1,5 @@ +.. role:: modname + :class: modname + +.. role:: title + :class: title diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 00000000..1c3a521d --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,5 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/index.rst + +Table of Contents +================= +.. include:: toc.rst diff --git a/docs/source/toc.rst b/docs/source/toc.rst new file mode 100644 index 00000000..b9c571cc --- /dev/null +++ b/docs/source/toc.rst @@ -0,0 +1,24 @@ +.. toctree:: + :maxdepth: 2 + :caption: About + + about/overview + about/installation + about/docker + about/usage + +.. toctree:: + :maxdepth: 2 + :caption: Contributing + + contributing/database + contributing/build + contributing/testing + +.. toctree:: + :maxdepth: 0 + :caption: Plugin Code + :titlesonly: + + code_docs/main + code_docs/plex_api_helper diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..235c06c2 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,8 @@ +# development environment requirements, these should not be distributed +flake8==3.9.2;python_version<"3" +m2r2==0.3.2;python_version<"3" +numpydoc==0.9.2;python_version<"3" +git+https://github.com/LizardByte/plexhints.git#egg=plexhints # type hinting library for plex development +pytest==4.6.11;python_version<"3" +Sphinx==1.8.6;python_version<"3" +sphinx-rtd-theme==1.0.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..08b525d4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# plex plugin requirements +-r Contents/Libraries/Shared/requirements.txt diff --git a/scripts/build_plist.py b/scripts/build_plist.py new file mode 100644 index 00000000..b6d6c21a --- /dev/null +++ b/scripts/build_plist.py @@ -0,0 +1,110 @@ +import os +import plistlib + +version = os.getenv('BUILD_VERSION', None) +print('version: %s' % version) + +commit = os.getenv('GITHUB_SHA', 'development build') +print('commit: %s' % commit) + +if not version: + checked = '' + if commit != 'development build': + version = commit[0:7] + print('using commit as version: %s' % version) + else: + version = commit + print('unknown version: %s' % version) +else: + checked = '' + +info_file = os.path.join('Contents', 'Info.plist') + +pl = dict( + CFBundleIdentifier='dev.lizardbyte.themerr-plex', + PlexAgentAttributionText=""" + + + + +
+ Themerr-plex
+
+
+ A plugin by LizardByte that adds theme songs to + movies. +
+
+ + + + + + +
Version: %s%s| Releases
+
+ + + + + +
Reference:| Docs
+ ]]> + """ % (checked, version), + CFBundleDevelopmentRegion='English', + CFBundleExecutable='', + CFBundlePackageType='AAPL', + CFBundleSignature='hook', + PlexFrameworkVersion='2', + PlexClientPlatforms='', + PlexClientPlatformExclusions='', + PlexPluginClass='Agent', + PlexPluginCodePolicy='Elevated', + PlexPluginConsoleLogging='0', + PlexPluginDebug='1', + PlexPluginMode='Agent', + PlexPluginRegions=[''], + PlexBundleVersion=version, + PlexShortBundleVersion=version, +) + +# PlexPluginMode: +# This one does nothing with a value of "Always On", a value of "daemon" keeps the plugin alive in the background. + +# PlexClientPlatforms and PlexClientPlatformExclusions: +# Any Clients support or not supported by the plugin. +# Possible values are * for all platforms, MacOSX, Windows, Linux, Roku, Android, iOS, Safari, Firefox, Chrome, LGTV, \ +# Samsung, PlexConnect and Plex Home Theater + +# PlexPluginRegions: +# Possible string values are the proper ISO two letter code for the country. +# A full list of values are available at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + +# PlexPluginDebug: +# Possible values are 0 and 1. Setting it to "1" rather than "0" turns on debug logging + +# PlexPluginCodePolicy: +# This allows channels to access some python methods which are otherwise blocked, as well as import external code \ +# libraries, and interact with the PMS HTTP API + +# PlexPluginClass: +# This key is used to show that the plugin is an agent. possible values are 'Agent' and 'Resource' + +# PlexPluginConsoleLogging: +# This is used to send plugin log statements directly to stout when running PMS from the command line. \ +# Rarely used anymore + +with open(info_file, 'wb') as fp: + try: + plistlib.dump(value=pl, fp=fp) # python 3 + except AttributeError: + plistlib.writePlist(pl, pathOrFile=fp) # python 2.7 diff --git a/scripts/install_requirements.py b/scripts/install_requirements.py new file mode 100644 index 00000000..40b29eac --- /dev/null +++ b/scripts/install_requirements.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python2.7 +import os +import subprocess +import sys + + +def main(): + # update pip + subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip']) + + # install agent requirements + shared_directory = os.path.join('Contents', 'Libraries', 'Shared') + + subprocess.check_call([ + sys.executable, '-m', 'pip', 'install', '--upgrade', '--target=%s' % shared_directory, '-r', + os.path.join(shared_directory, 'requirements.txt'), '--no-warn-script-location' + ]) + + +if __name__ == '__main__': + main()