├── .docker_platforms ├── .dockerignore ├── .flake8 ├── .github ├── dependabot.yml ├── label-actions.yml └── workflows │ ├── CI.yml │ ├── ci-docker.yml │ ├── codeql.yml │ ├── issues.yml │ ├── python-flake8.yml │ ├── release-notifier.yml │ ├── update-changelog.yml │ ├── update-docs.yml │ └── yaml-lint.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yaml ├── .rstcheck.cfg ├── Contents ├── Code │ ├── __init__.py │ └── default_prefs.py ├── Resources │ ├── attribution.png │ ├── favicon.ico │ └── icon-default.png ├── Services │ ├── ServiceInfo.plist │ └── URL │ │ └── YouTube │ │ ├── ServiceCode.pys │ │ └── ServicePrefs.json └── Strings │ ├── de.json │ ├── en-gb.json │ ├── en-us.json │ ├── en.json │ ├── es.json │ ├── fr.json │ ├── it.json │ ├── ja.json │ ├── pt.json │ ├── ru.json │ ├── sv.json │ └── zh.json ├── DOCKER_README.md ├── Dockerfile ├── LICENSE ├── README.rst ├── codecov.yml ├── crowdin.yml ├── docs ├── Makefile ├── make.bat └── source │ ├── about │ ├── changelog.rst │ ├── docker.rst │ ├── installation.rst │ ├── overview.rst │ └── usage.rst │ ├── code_docs │ ├── main.rst │ └── youtube.rst │ ├── conf.py │ ├── contributing │ ├── build.rst │ ├── contributing.rst │ └── testing.rst │ ├── global.rst │ ├── index.rst │ └── toc.rst ├── requirements-dev.txt ├── requirements.txt ├── scripts └── build_plist.py └── tests ├── __init__.py ├── conftest.py ├── functional ├── __init__.py └── test_docs.py └── unit ├── __init__.py ├── test_code.py └── url_services ├── __init__.py ├── conftest.py └── test_youtube.py /.docker_platforms: -------------------------------------------------------------------------------- 1 | linux/amd64,linux/arm64/v8,linux/arm/v7 -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # ignore git files 2 | .git* 3 | 4 | # ignore hidden files 5 | .* 6 | 7 | # ignore directories 8 | docs/ 9 | tests/ 10 | venv/ 11 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | filename = 3 | *.py, 4 | *.pys 5 | max-line-length = 120 6 | extend-exclude = 7 | venv/ 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This file is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "docker" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | time: "08:00" 13 | open-pull-requests-limit: 10 14 | 15 | - package-ecosystem: "github-actions" 16 | directory: "/" 17 | schedule: 18 | interval: "daily" 19 | time: "08:30" 20 | open-pull-requests-limit: 10 21 | 22 | - package-ecosystem: "npm" 23 | directory: "/" 24 | schedule: 25 | interval: "daily" 26 | time: "09:00" 27 | open-pull-requests-limit: 10 28 | 29 | - package-ecosystem: "nuget" 30 | directory: "/" 31 | schedule: 32 | interval: "daily" 33 | time: "09:30" 34 | open-pull-requests-limit: 10 35 | 36 | - package-ecosystem: "pip" 37 | directory: "/" 38 | schedule: 39 | interval: "daily" 40 | time: "10:00" 41 | open-pull-requests-limit: 10 42 | 43 | - package-ecosystem: "gitsubmodule" 44 | directory: "/" 45 | schedule: 46 | interval: "daily" 47 | time: "10:30" 48 | open-pull-requests-limit: 10 49 | -------------------------------------------------------------------------------- /.github/label-actions.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This file is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # Configuration for Label Actions - https://github.com/dessant/label-actions 7 | 8 | added: 9 | comment: > 10 | This feature has been added and will be available in the next release. 11 | fixed: 12 | comment: > 13 | This issue has been fixed and will be available in the next release. 14 | invalid:duplicate: 15 | comment: > 16 | :wave: @{issue-author}, this appears to be a duplicate of a pre-existing issue. 17 | close: true 18 | lock: true 19 | unlabel: 'status:awaiting-triage' 20 | 21 | -invalid:duplicate: 22 | reopen: true 23 | unlock: true 24 | 25 | invalid:support: 26 | comment: > 27 | :wave: @{issue-author}, we use the issue tracker exclusively for bug reports. 28 | However, this issue appears to be a support request. Please use our 29 | [Support Center](https://app.lizardbyte.dev/support) for support issues. Thanks. 30 | close: true 31 | lock: true 32 | lock-reason: 'off-topic' 33 | unlabel: 'status:awaiting-triage' 34 | 35 | -invalid:support: 36 | reopen: true 37 | unlock: true 38 | 39 | invalid:template-incomplete: 40 | issues: 41 | comment: > 42 | :wave: @{issue-author}, please edit your issue to complete the template with 43 | all the required info. Your issue will be automatically closed in 5 days if 44 | the template is not completed. Thanks. 45 | prs: 46 | comment: > 47 | :wave: @{issue-author}, please edit your PR to complete the template with 48 | all the required info. Your PR will be automatically closed in 5 days if 49 | the template is not completed. Thanks. 50 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 4 | on: 5 | pull_request: 6 | branches: [master] 7 | types: [opened, synchronize, reopened] 8 | push: 9 | branches: [master] 10 | workflow_dispatch: 11 | 12 | concurrency: 13 | group: "${{ github.workflow }}-${{ github.ref }}" 14 | cancel-in-progress: true 15 | 16 | jobs: 17 | setup_release: 18 | name: Setup Release 19 | outputs: 20 | publish_release: ${{ steps.setup_release.outputs.publish_release }} 21 | release_body: ${{ steps.setup_release.outputs.release_body }} 22 | release_commit: ${{ steps.setup_release.outputs.release_commit }} 23 | release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }} 24 | release_tag: ${{ steps.setup_release.outputs.release_tag }} 25 | release_version: ${{ steps.setup_release.outputs.release_version }} 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: Checkout 29 | uses: actions/checkout@v4 30 | 31 | - name: Setup Release 32 | id: setup_release 33 | uses: LizardByte/setup-release-action@v2024.801.192524 34 | with: 35 | github_token: ${{ secrets.GITHUB_TOKEN }} 36 | 37 | build: 38 | needs: 39 | - setup_release 40 | runs-on: ubuntu-20.04 41 | 42 | steps: 43 | - name: Checkout 44 | uses: actions/checkout@v4 45 | with: 46 | path: PlexyGlass.bundle 47 | submodules: recursive 48 | 49 | - name: Set up Python 50 | uses: LizardByte/setup-python-action@v2024.609.5111 51 | with: 52 | python-version: '2.7' 53 | 54 | - name: Patch third-party deps 55 | if: false # disabled 56 | shell: bash 57 | working-directory: PlexyGlass.bundle/third-party 58 | run: | 59 | patch_dir=${{ github.workspace }}/PlexyGlass.bundle/patches 60 | 61 | # youtube-dl patches 62 | pushd youtube-dl 63 | git apply -v "${patch_dir}/youtube_dl-compat.patch" 64 | popd 65 | 66 | - name: Set up Python Dependencies 67 | shell: bash 68 | working-directory: PlexyGlass.bundle 69 | run: | 70 | echo "Installing Requirements" 71 | python --version 72 | python -m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip setuptools 73 | 74 | # install dev requirements 75 | python -m pip install --upgrade -r requirements-dev.txt 76 | 77 | python -m pip install --upgrade --target=./Contents/Libraries/Shared -r \ 78 | requirements.txt --no-warn-script-location 79 | 80 | - name: Build plist 81 | working-directory: PlexyGlass.bundle 82 | env: 83 | BUILD_VERSION: ${{ needs.setup_release.outputs.release_tag }} 84 | run: | 85 | python ./scripts/build_plist.py 86 | 87 | - name: Package Release 88 | shell: bash 89 | run: | 90 | 7z \ 91 | "-xr!*.git*" \ 92 | "-xr!*.pyc" \ 93 | "-xr!__pycache__" \ 94 | "-xr!plexhints*" \ 95 | "-xr!PlexyGlass.bundle/.*" \ 96 | "-xr!PlexyGlass.bundle/cache.sqlite" \ 97 | "-xr!PlexyGlass.bundle/DOCKER_README.md" \ 98 | "-xr!PlexyGlass.bundle/Dockerfile" \ 99 | "-xr!PlexyGlass.bundle/docs" \ 100 | "-xr!PlexyGlass.bundle/scripts" \ 101 | a "./PlexyGlass.bundle.zip" "PlexyGlass.bundle" 102 | 103 | mkdir artifacts 104 | mv ./PlexyGlass.bundle.zip ./artifacts/ 105 | 106 | - name: Upload Artifacts 107 | uses: actions/upload-artifact@v4 108 | with: 109 | name: PlexyGlass.bundle 110 | if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` 111 | path: | 112 | ${{ github.workspace }}/artifacts 113 | 114 | - name: Create/Update GitHub Release 115 | if: ${{ needs.setup_release.outputs.publish_release == 'true' }} 116 | uses: LizardByte/create-release-action@v2024.614.221009 117 | with: 118 | allowUpdates: true 119 | body: ${{ needs.setup_release.outputs.release_body }} 120 | discussionCategory: announcements 121 | generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }} 122 | name: ${{ needs.setup_release.outputs.release_tag }} 123 | prerelease: true 124 | tag: ${{ needs.setup_release.outputs.release_tag }} 125 | token: ${{ secrets.GH_BOT_TOKEN }} 126 | 127 | pytest: 128 | needs: [build] 129 | strategy: 130 | fail-fast: false 131 | matrix: 132 | os: [windows-latest, ubuntu-latest, macos-latest] 133 | 134 | runs-on: ${{ matrix.os }} 135 | steps: 136 | - name: Checkout 137 | uses: actions/checkout@v4 138 | 139 | - name: Download artifacts 140 | uses: actions/download-artifact@v4 141 | with: 142 | name: PlexyGlass.bundle 143 | 144 | - name: Extract artifacts zip 145 | shell: bash 146 | run: | 147 | # extract zip 148 | 7z x PlexyGlass.bundle.zip -o. 149 | 150 | # move all files from "PlexyGlass.bundle" to root, with no target directory 151 | cp -r ./PlexyGlass.bundle/. . 152 | 153 | # remove zip 154 | rm PlexyGlass.bundle.zip 155 | 156 | - name: Set up Python 157 | uses: LizardByte/setup-python-action@v2024.609.5111 158 | with: 159 | python-version: '2.7' 160 | 161 | - name: Install python dependencies 162 | shell: bash 163 | run: | 164 | python -m pip --no-python-version-warning --disable-pip-version-check install --upgrade \ 165 | pip setuptools wheel 166 | python -m pip --no-python-version-warning --disable-pip-version-check install --no-build-isolation \ 167 | -r requirements-dev.txt 168 | 169 | - name: Test with pytest 170 | id: test 171 | shell: bash 172 | run: | 173 | python -m pytest \ 174 | -rxXs \ 175 | --tb=native \ 176 | --verbose \ 177 | --color=yes \ 178 | --cov=Contents/Code \ 179 | --cov=Contents/Services \ 180 | tests 181 | 182 | - name: Upload coverage 183 | # any except canceled or skipped 184 | if: >- 185 | always() && 186 | (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && 187 | startsWith(github.repository, 'LizardByte/') 188 | uses: codecov/codecov-action@v4 189 | with: 190 | fail_ci_if_error: true 191 | flags: ${{ runner.os }} 192 | token: ${{ secrets.CODECOV_TOKEN }} 193 | -------------------------------------------------------------------------------- /.github/workflows/ci-docker.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # This workflow is intended to work with all our organization Docker projects. A readme named `DOCKER_README.md` 7 | # will be used to update the description on Docker hub. 8 | 9 | # custom comments in dockerfiles: 10 | 11 | # `# platforms: ` 12 | # Comma separated list of platforms, i.e. `# platforms: linux/386,linux/amd64`. Docker platforms can alternatively 13 | # be listed in a file named `.docker_platforms`. 14 | # `# platforms_pr: ` 15 | # Comma separated list of platforms to run for PR events, i.e. `# platforms_pr: linux/amd64`. This will take 16 | # precedence over the `# platforms: ` directive. 17 | # `# artifacts: ` 18 | # `true` to build in two steps, stopping at `artifacts` build stage and extracting the image from there to the 19 | # GitHub runner. 20 | 21 | name: CI Docker 22 | 23 | on: 24 | pull_request: 25 | branches: [master] 26 | types: [opened, synchronize, reopened] 27 | push: 28 | branches: [master] 29 | workflow_dispatch: 30 | 31 | concurrency: 32 | group: "${{ github.workflow }}-${{ github.ref }}" 33 | cancel-in-progress: true 34 | 35 | jobs: 36 | check_dockerfiles: 37 | name: Check Dockerfiles 38 | runs-on: ubuntu-latest 39 | steps: 40 | - name: Checkout 41 | uses: actions/checkout@v4 42 | 43 | - name: Find dockerfiles 44 | id: find 45 | run: | 46 | dockerfiles=$(find . -type f -iname "Dockerfile" -o -iname "*.dockerfile") 47 | 48 | echo "found dockerfiles: ${dockerfiles}" 49 | 50 | # do not quote to keep this as a single line 51 | echo dockerfiles=${dockerfiles} >> $GITHUB_OUTPUT 52 | 53 | MATRIX_COMBINATIONS="" 54 | for FILE in ${dockerfiles}; do 55 | # extract tag from file name 56 | tag=$(echo $FILE | sed -r -z -e 's/(\.\/)*.*\/(Dockerfile)/None/gm') 57 | if [[ $tag == "None" ]]; then 58 | MATRIX_COMBINATIONS="$MATRIX_COMBINATIONS {\"dockerfile\": \"$FILE\"}," 59 | else 60 | tag=$(echo $FILE | sed -r -z -e 's/(\.\/)*.*\/(.+)(\.dockerfile)/-\2/gm') 61 | MATRIX_COMBINATIONS="$MATRIX_COMBINATIONS {\"dockerfile\": \"$FILE\", \"tag\": \"$tag\"}," 62 | fi 63 | done 64 | 65 | # removes the last character (i.e. comma) 66 | MATRIX_COMBINATIONS=${MATRIX_COMBINATIONS::-1} 67 | 68 | # setup matrix for later jobs 69 | matrix=$(( 70 | echo "{ \"include\": [$MATRIX_COMBINATIONS] }" 71 | ) | jq -c .) 72 | 73 | echo $matrix 74 | echo $matrix | jq . 75 | echo "matrix=$matrix" >> $GITHUB_OUTPUT 76 | 77 | - name: Find dotnet solution file 78 | id: find_dotnet 79 | run: | 80 | solution=$(find . -maxdepth 1 -type f -iname "*.sln") 81 | 82 | echo "found solution: ${solution}" 83 | 84 | # do not quote to keep this as a single line 85 | echo solution=${solution} >> $GITHUB_OUTPUT 86 | 87 | if [[ $solution != "" ]]; then 88 | echo "dotnet=true" >> $GITHUB_OUTPUT 89 | else 90 | echo "dotnet=false" >> $GITHUB_OUTPUT 91 | fi 92 | 93 | outputs: 94 | dockerfiles: ${{ steps.find.outputs.dockerfiles }} 95 | matrix: ${{ steps.find.outputs.matrix }} 96 | dotnet: ${{ steps.find_dotnet.outputs.dotnet }} 97 | solution: ${{ steps.find_dotnet.outputs.solution }} 98 | 99 | setup_release: 100 | if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} 101 | name: Setup Release 102 | needs: 103 | - check_dockerfiles 104 | outputs: 105 | publish_release: ${{ steps.setup_release.outputs.publish_release }} 106 | release_body: ${{ steps.setup_release.outputs.release_body }} 107 | release_commit: ${{ steps.setup_release.outputs.release_commit }} 108 | release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }} 109 | release_tag: ${{ steps.setup_release.outputs.release_tag }} 110 | release_version: ${{ steps.setup_release.outputs.release_version }} 111 | runs-on: ubuntu-latest 112 | steps: 113 | - name: Checkout 114 | uses: actions/checkout@v4 115 | 116 | - name: Setup Release 117 | id: setup_release 118 | uses: LizardByte/setup-release-action@v2024.801.192524 119 | with: 120 | dotnet: ${{ needs.check_dockerfiles.outputs.dotnet }} 121 | github_token: ${{ secrets.GITHUB_TOKEN }} 122 | 123 | lint_dockerfile: 124 | needs: [check_dockerfiles] 125 | if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} 126 | runs-on: ubuntu-latest 127 | strategy: 128 | fail-fast: false 129 | matrix: ${{ fromJson(needs.check_dockerfiles.outputs.matrix) }} 130 | name: Lint Dockerfile${{ matrix.tag }} 131 | 132 | steps: 133 | - name: Checkout 134 | uses: actions/checkout@v4 135 | 136 | - name: Hadolint 137 | id: hadolint 138 | uses: hadolint/hadolint-action@v3.1.0 139 | with: 140 | dockerfile: ${{ matrix.dockerfile }} 141 | ignore: DL3008,DL3013,DL3016,DL3018,DL3028,DL3059 142 | output-file: ./hadolint.log 143 | verbose: true 144 | 145 | - name: Log 146 | if: failure() 147 | run: | 148 | echo "Hadolint outcome: ${{ steps.hadolint.outcome }}" >> $GITHUB_STEP_SUMMARY 149 | cat "./hadolint.log" >> $GITHUB_STEP_SUMMARY 150 | 151 | docker: 152 | needs: [check_dockerfiles, setup_release] 153 | if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} 154 | runs-on: ubuntu-latest 155 | permissions: 156 | packages: write 157 | contents: write 158 | strategy: 159 | fail-fast: false 160 | matrix: ${{ fromJson(needs.check_dockerfiles.outputs.matrix) }} 161 | name: Docker${{ matrix.tag }} 162 | 163 | steps: 164 | - name: Maximize build space 165 | uses: easimon/maximize-build-space@v10 166 | with: 167 | root-reserve-mb: 30720 # https://github.com/easimon/maximize-build-space#caveats 168 | remove-dotnet: 'true' 169 | remove-android: 'true' 170 | remove-haskell: 'true' 171 | remove-codeql: 'true' 172 | remove-docker-images: 'true' 173 | 174 | - name: Checkout 175 | uses: actions/checkout@v4 176 | with: 177 | submodules: recursive 178 | 179 | - name: Prepare 180 | id: prepare 181 | env: 182 | NV: ${{ needs.setup_release.outputs.release_tag }} 183 | run: | 184 | # get branch name 185 | BRANCH=${GITHUB_HEAD_REF} 186 | 187 | RELEASE=${{ needs.setup_release.outputs.publish_release }} 188 | COMMIT=${{ needs.setup_release.outputs.release_commit }} 189 | 190 | if [ -z "$BRANCH" ]; then 191 | echo "This is a PUSH event" 192 | BRANCH=${{ github.ref_name }} 193 | CLONE_URL=${{ github.event.repository.clone_url }} 194 | else 195 | echo "This is a PULL REQUEST event" 196 | CLONE_URL=${{ github.event.pull_request.head.repo.clone_url }} 197 | fi 198 | 199 | # determine to push image to dockerhub and ghcr or not 200 | if [[ $GITHUB_EVENT_NAME == "push" ]]; then 201 | PUSH=true 202 | else 203 | PUSH=false 204 | fi 205 | 206 | # setup the tags 207 | REPOSITORY=${{ github.repository }} 208 | BASE_TAG=$(echo $REPOSITORY | tr '[:upper:]' '[:lower:]') 209 | 210 | TAGS="${BASE_TAG}:${COMMIT:0:7}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${COMMIT:0:7}${{ matrix.tag }}" 211 | 212 | if [[ $GITHUB_REF == refs/heads/master ]]; then 213 | TAGS="${TAGS},${BASE_TAG}:latest${{ matrix.tag }},ghcr.io/${BASE_TAG}:latest${{ matrix.tag }}" 214 | TAGS="${TAGS},${BASE_TAG}:master${{ matrix.tag }},ghcr.io/${BASE_TAG}:master${{ matrix.tag }}" 215 | else 216 | TAGS="${TAGS},${BASE_TAG}:test${{ matrix.tag }},ghcr.io/${BASE_TAG}:test${{ matrix.tag }}" 217 | fi 218 | 219 | if [[ ${NV} != "" ]]; then 220 | TAGS="${TAGS},${BASE_TAG}:${NV}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${NV}${{ matrix.tag }}" 221 | fi 222 | 223 | # parse custom directives out of dockerfile 224 | # try to get the platforms from the dockerfile custom directive, i.e. `# platforms: xxx,yyy` 225 | # directives for PR event, i.e. not push event 226 | if [[ ${RELEASE} == "false" ]]; then 227 | while read -r line; do 228 | if [[ $line == "# platforms_pr: "* && $PLATFORMS == "" ]]; then 229 | # echo the line and use `sed` to remove the custom directive 230 | PLATFORMS=$(echo -e "$line" | sed 's/# platforms_pr: //') 231 | elif [[ $PLATFORMS != "" ]]; then 232 | # break while loop once all custom "PR" event directives are found 233 | break 234 | fi 235 | done <"${{ matrix.dockerfile }}" 236 | fi 237 | # directives for all events... above directives will not be parsed if they were already found 238 | while read -r line; do 239 | if [[ $line == "# platforms: "* && $PLATFORMS == "" ]]; then 240 | # echo the line and use `sed` to remove the custom directive 241 | PLATFORMS=$(echo -e "$line" | sed 's/# platforms: //') 242 | elif [[ $line == "# artifacts: "* && $ARTIFACTS == "" ]]; then 243 | # echo the line and use `sed` to remove the custom directive 244 | ARTIFACTS=$(echo -e "$line" | sed 's/# artifacts: //') 245 | elif [[ $line == "# no-cache-filters: "* && $NO_CACHE_FILTERS == "" ]]; then 246 | # echo the line and use `sed` to remove the custom directive 247 | NO_CACHE_FILTERS=$(echo -e "$line" | sed 's/# no-cache-filters: //') 248 | elif [[ $PLATFORMS != "" && $ARTIFACTS != "" && $NO_CACHE_FILTERS != "" ]]; then 249 | # break while loop once all custom directives are found 250 | break 251 | fi 252 | done <"${{ matrix.dockerfile }}" 253 | # if PLATFORMS is blank, fall back to the legacy method of reading from the `.docker_platforms` file 254 | if [[ $PLATFORMS == "" ]]; then 255 | # read the platforms from `.docker_platforms` 256 | PLATFORMS=$(<.docker_platforms) 257 | fi 258 | # if PLATFORMS is still blank, fall back to `linux/amd64` 259 | if [[ $PLATFORMS == "" ]]; then 260 | PLATFORMS="linux/amd64" 261 | fi 262 | 263 | echo "branch=${BRANCH}" >> $GITHUB_OUTPUT 264 | echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT 265 | echo "clone_url=${CLONE_URL}" >> $GITHUB_OUTPUT 266 | echo "artifacts=${ARTIFACTS}" >> $GITHUB_OUTPUT 267 | echo "no_cache_filters=${NO_CACHE_FILTERS}" >> $GITHUB_OUTPUT 268 | echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT 269 | echo "tags=${TAGS}" >> $GITHUB_OUTPUT 270 | 271 | - name: Set Up QEMU 272 | uses: docker/setup-qemu-action@v3 273 | 274 | - name: Set up Docker Buildx 275 | uses: docker/setup-buildx-action@v3 276 | id: buildx 277 | 278 | - name: Cache Docker Layers 279 | uses: actions/cache@v4 280 | with: 281 | path: /tmp/.buildx-cache 282 | key: Docker-buildx${{ matrix.tag }}-${{ github.sha }} 283 | restore-keys: | 284 | Docker-buildx${{ matrix.tag }}- 285 | 286 | - name: Log in to Docker Hub 287 | if: ${{ needs.setup_release.outputs.publish_release == 'true' }} # PRs do not have access to secrets 288 | uses: docker/login-action@v3 289 | with: 290 | username: ${{ secrets.DOCKER_HUB_USERNAME }} 291 | password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} 292 | 293 | - name: Log in to the Container registry 294 | if: ${{ needs.setup_release.outputs.publish_release == 'true' }} # PRs do not have access to secrets 295 | uses: docker/login-action@v3 296 | with: 297 | registry: ghcr.io 298 | username: ${{ secrets.GH_BOT_NAME }} 299 | password: ${{ secrets.GH_BOT_TOKEN }} 300 | 301 | - name: Build artifacts 302 | if: ${{ steps.prepare.outputs.artifacts == 'true' }} 303 | id: build_artifacts 304 | uses: docker/build-push-action@v6 305 | with: 306 | context: ./ 307 | file: ${{ matrix.dockerfile }} 308 | target: artifacts 309 | outputs: type=local,dest=artifacts 310 | push: false 311 | platforms: ${{ steps.prepare.outputs.platforms }} 312 | build-args: | 313 | BRANCH=${{ steps.prepare.outputs.branch }} 314 | BUILD_DATE=${{ steps.prepare.outputs.build_date }} 315 | BUILD_VERSION=${{ needs.setup_release.outputs.release_tag }} 316 | COMMIT=${{ needs.setup_release.outputs.release_commit }} 317 | CLONE_URL=${{ steps.prepare.outputs.clone_url }} 318 | RELEASE=${{ needs.setup_release.outputs.publish_release }} 319 | tags: ${{ steps.prepare.outputs.tags }} 320 | cache-from: type=local,src=/tmp/.buildx-cache 321 | cache-to: type=local,dest=/tmp/.buildx-cache 322 | no-cache-filters: ${{ steps.prepare.outputs.no_cache_filters }} 323 | 324 | - name: Build and push 325 | id: build 326 | uses: docker/build-push-action@v6 327 | with: 328 | context: ./ 329 | file: ${{ matrix.dockerfile }} 330 | push: ${{ needs.setup_release.outputs.publish_release }} 331 | platforms: ${{ steps.prepare.outputs.platforms }} 332 | build-args: | 333 | BRANCH=${{ steps.prepare.outputs.branch }} 334 | BUILD_DATE=${{ steps.prepare.outputs.build_date }} 335 | BUILD_VERSION=${{ needs.setup_release.outputs.release_tag }} 336 | COMMIT=${{ needs.setup_release.outputs.release_commit }} 337 | CLONE_URL=${{ steps.prepare.outputs.clone_url }} 338 | RELEASE=${{ needs.setup_release.outputs.publish_release }} 339 | tags: ${{ steps.prepare.outputs.tags }} 340 | cache-from: type=local,src=/tmp/.buildx-cache 341 | cache-to: type=local,dest=/tmp/.buildx-cache 342 | no-cache-filters: ${{ steps.prepare.outputs.no_cache_filters }} 343 | 344 | - name: Arrange Artifacts 345 | if: ${{ steps.prepare.outputs.artifacts == 'true' }} 346 | working-directory: artifacts 347 | run: | 348 | # artifacts will be in sub directories named after the docker target platform, e.g. `linux_amd64` 349 | # so move files to the artifacts directory 350 | # https://unix.stackexchange.com/a/52816 351 | find ./ -type f -exec mv -t ./ -n '{}' + 352 | 353 | # remove provenance file 354 | rm -f ./provenance.json 355 | 356 | - name: Upload Artifacts 357 | if: ${{ steps.prepare.outputs.artifacts == 'true' }} 358 | uses: actions/upload-artifact@v4 359 | with: 360 | name: Docker${{ matrix.tag }} 361 | path: artifacts/ 362 | 363 | - name: Create/Update GitHub Release 364 | if: ${{ needs.setup_release.outputs.publish_release == 'true' && steps.prepare.outputs.artifacts == 'true' }} 365 | uses: LizardByte/create-release-action@v2024.614.221009 366 | with: 367 | allowUpdates: true 368 | artifacts: "*artifacts/*" 369 | body: ${{ needs.setup_release.outputs.release_body }} 370 | discussionCategory: announcements 371 | generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }} 372 | name: ${{ needs.setup_release.outputs.release_tag }} 373 | prerelease: true 374 | tag: ${{ needs.setup_release.outputs.release_tag }} 375 | token: ${{ secrets.GH_BOT_TOKEN }} 376 | 377 | - name: Update Docker Hub Description 378 | if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} 379 | uses: peter-evans/dockerhub-description@v4 380 | with: 381 | username: ${{ secrets.DOCKER_HUB_USERNAME }} 382 | password: ${{ secrets.DOCKER_HUB_PASSWORD }} # token is not currently supported 383 | repository: ${{ env.BASE_TAG }} 384 | short-description: ${{ github.event.repository.description }} 385 | readme-filepath: ./DOCKER_README.md 386 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # This workflow will analyze all supported languages in the repository using CodeQL Analysis. 7 | 8 | name: "CodeQL" 9 | 10 | on: 11 | push: 12 | branches: ["master"] 13 | pull_request: 14 | branches: ["master"] 15 | schedule: 16 | - cron: '00 12 * * 0' # every Sunday at 12:00 UTC 17 | 18 | concurrency: 19 | group: "${{ github.workflow }}-${{ github.ref }}" 20 | cancel-in-progress: true 21 | 22 | jobs: 23 | languages: 24 | name: Get language matrix 25 | runs-on: ubuntu-latest 26 | outputs: 27 | matrix: ${{ steps.lang.outputs.result }} 28 | continue: ${{ steps.continue.outputs.result }} 29 | steps: 30 | - name: Get repo languages 31 | uses: actions/github-script@v7 32 | id: lang 33 | with: 34 | script: | 35 | // CodeQL supports ['cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift'] 36 | // Use only 'java' to analyze code written in Java, Kotlin or both 37 | // Use only 'javascript' to analyze code written in JavaScript, TypeScript or both 38 | // Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 39 | const supported_languages = ['cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift'] 40 | 41 | const remap_languages = { 42 | 'c++': 'cpp', 43 | 'c#': 'csharp', 44 | 'kotlin': 'java', 45 | 'typescript': 'javascript', 46 | } 47 | 48 | const repo = context.repo 49 | const response = await github.rest.repos.listLanguages(repo) 50 | let matrix = { 51 | "include": [] 52 | } 53 | 54 | for (let [key, value] of Object.entries(response.data)) { 55 | // remap language 56 | if (remap_languages[key.toLowerCase()]) { 57 | console.log(`Remapping language: ${key} to ${remap_languages[key.toLowerCase()]}`) 58 | key = remap_languages[key.toLowerCase()] 59 | } 60 | if (supported_languages.includes(key.toLowerCase())) { 61 | console.log(`Found supported language: ${key}`) 62 | let osList = ['ubuntu-latest']; 63 | if (key.toLowerCase() === 'swift') { 64 | osList = ['macos-latest']; 65 | } else if (key.toLowerCase() === 'cpp') { 66 | // TODO: update macos to latest after the below issue is resolved 67 | // https://github.com/github/codeql-action/issues/2266 68 | osList = ['macos-13', 'ubuntu-latest', 'windows-latest']; 69 | } 70 | for (let os of osList) { 71 | // set name for matrix 72 | if (osList.length == 1) { 73 | name = key.toLowerCase() 74 | } else { 75 | name = `${key.toLowerCase()}, ${os}` 76 | } 77 | 78 | // add to matrix 79 | matrix['include'].push({"language": key.toLowerCase(), "os": os, "name": name}) 80 | } 81 | } 82 | } 83 | 84 | // print languages 85 | console.log(`matrix: ${JSON.stringify(matrix)}`) 86 | 87 | return matrix 88 | 89 | - name: Continue 90 | uses: actions/github-script@v7 91 | id: continue 92 | with: 93 | script: | 94 | // if matrix['include'] is an empty list return false, otherwise true 95 | const matrix = ${{ steps.lang.outputs.result }} // this is already json encoded 96 | 97 | if (matrix['include'].length == 0) { 98 | return false 99 | } else { 100 | return true 101 | } 102 | 103 | analyze: 104 | name: Analyze (${{ matrix.name }}) 105 | if: ${{ needs.languages.outputs.continue == 'true' }} 106 | defaults: 107 | run: 108 | shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }} 109 | env: 110 | GITHUB_CODEQL_BUILD: true 111 | needs: [languages] 112 | runs-on: ${{ matrix.os || 'ubuntu-latest' }} 113 | timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} 114 | permissions: 115 | actions: read 116 | contents: read 117 | security-events: write 118 | 119 | strategy: 120 | fail-fast: false 121 | matrix: ${{ fromJson(needs.languages.outputs.matrix) }} 122 | 123 | steps: 124 | - name: Maximize build space 125 | if: >- 126 | runner.os == 'Linux' && 127 | matrix.language == 'cpp' 128 | uses: easimon/maximize-build-space@v10 129 | with: 130 | root-reserve-mb: 30720 131 | remove-dotnet: ${{ (matrix.language == 'csharp' && 'false') || 'true' }} 132 | remove-android: 'true' 133 | remove-haskell: 'true' 134 | remove-codeql: 'false' 135 | remove-docker-images: 'true' 136 | 137 | - name: Checkout repository 138 | uses: actions/checkout@v4 139 | with: 140 | submodules: recursive 141 | 142 | - name: Setup msys2 143 | if: >- 144 | runner.os == 'Windows' && 145 | matrix.language == 'cpp' 146 | uses: msys2/setup-msys2@v2 147 | with: 148 | msystem: ucrt64 149 | update: true 150 | 151 | # Initializes the CodeQL tools for scanning. 152 | - name: Initialize CodeQL 153 | uses: github/codeql-action/init@v3 154 | with: 155 | languages: ${{ matrix.language }} 156 | # If you wish to specify custom queries, you can do so here or in a config file. 157 | # By default, queries listed here will override any specified in a config file. 158 | # Prefix the list here with "+" to use these queries and those in the config file. 159 | 160 | # yamllint disable-line rule:line-length 161 | # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 162 | # queries: security-extended,security-and-quality 163 | config: | 164 | paths-ignore: 165 | - build 166 | - node_modules 167 | - third-party 168 | 169 | # Pre autobuild 170 | # create a file named .codeql-prebuild-${{ matrix.language }}.sh in the root of your repository 171 | # create a file named .codeql-build-${{ matrix.language }}.sh in the root of your repository 172 | - name: Prebuild 173 | id: prebuild 174 | run: | 175 | # check if prebuild script exists 176 | filename=".codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh" 177 | if [ -f "./${filename}" ]; then 178 | echo "Running prebuild script: ${filename}" 179 | ./${filename} 180 | fi 181 | 182 | # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). 183 | - name: Autobuild 184 | if: steps.prebuild.outputs.skip_autobuild != 'true' 185 | uses: github/codeql-action/autobuild@v3 186 | 187 | - name: Perform CodeQL Analysis 188 | uses: github/codeql-action/analyze@v3 189 | with: 190 | category: "/language:${{matrix.language}}" 191 | output: sarif-results 192 | upload: failure-only 193 | 194 | - name: filter-sarif 195 | uses: advanced-security/filter-sarif@v1 196 | with: 197 | input: sarif-results/${{ matrix.language }}.sarif 198 | output: sarif-results/${{ matrix.language }}.sarif 199 | patterns: | 200 | -build/** 201 | -node_modules/** 202 | -third\-party/** 203 | 204 | - name: Upload SARIF 205 | uses: github/codeql-action/upload-sarif@v3 206 | with: 207 | sarif_file: sarif-results/${{ matrix.language }}.sarif 208 | 209 | - name: Upload loc as a Build Artifact 210 | uses: actions/upload-artifact@v4 211 | with: 212 | name: sarif-results-${{ matrix.language }}-${{ runner.os }} 213 | path: sarif-results 214 | retention-days: 1 215 | -------------------------------------------------------------------------------- /.github/workflows/issues.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # Label and un-label actions using `../label-actions.yml`. 7 | 8 | name: Issues 9 | 10 | on: 11 | issues: 12 | types: [labeled, unlabeled] 13 | discussion: 14 | types: [labeled, unlabeled] 15 | 16 | jobs: 17 | label: 18 | name: Label Actions 19 | if: startsWith(github.repository, 'LizardByte/') 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Label Actions 23 | uses: dessant/label-actions@v4 24 | with: 25 | github-token: ${{ secrets.GH_BOT_TOKEN }} 26 | -------------------------------------------------------------------------------- /.github/workflows/python-flake8.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # Lint python files with flake8. 7 | 8 | name: flake8 9 | 10 | on: 11 | pull_request: 12 | branches: [master] 13 | types: [opened, synchronize, reopened] 14 | 15 | concurrency: 16 | group: "${{ github.workflow }}-${{ github.ref }}" 17 | cancel-in-progress: true 18 | 19 | jobs: 20 | flake8: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v4 25 | 26 | - name: Set up Python 27 | uses: actions/setup-python@v5 # https://github.com/actions/setup-python 28 | with: 29 | python-version: '3.10' 30 | 31 | - name: Install dependencies 32 | run: | 33 | # pin flake8 before v6.0.0 due to removal of support for type comments (required for Python 2.7 type hints) 34 | python -m pip install --upgrade pip setuptools "flake8<6" 35 | 36 | - name: Test with flake8 37 | run: | 38 | python -m flake8 --verbose 39 | -------------------------------------------------------------------------------- /.github/workflows/release-notifier.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # Send release notification to various platforms. 7 | 8 | name: Release Notifications 9 | 10 | on: 11 | release: 12 | types: 13 | - released # this triggers when a release is published, but does not include pre-releases or drafts 14 | 15 | jobs: 16 | simplified_changelog: 17 | if: >- 18 | startsWith(github.repository, 'LizardByte/') && 19 | !github.event.release.prerelease && 20 | !github.event.release.draft 21 | outputs: 22 | SIMPLIFIED_BODY: ${{ steps.output.outputs.SIMPLIFIED_BODY }} 23 | runs-on: ubuntu-latest 24 | steps: 25 | - name: remove contributors section 26 | env: 27 | RELEASE_BODY: ${{ github.event.release.body }} 28 | id: output 29 | run: | 30 | echo "${RELEASE_BODY}" > ./release_body.md 31 | modified_body=$(sed '/^---$/d; /^## Contributors$/,/<\/a>/d' ./release_body.md) 32 | echo "modified_body: ${modified_body}" 33 | 34 | # use a heredoc to ensure the output is multiline 35 | echo "SIMPLIFIED_BODY<> $GITHUB_OUTPUT 36 | echo "${modified_body}" >> $GITHUB_OUTPUT 37 | echo "EOF" >> $GITHUB_OUTPUT 38 | 39 | discord: 40 | if: >- 41 | startsWith(github.repository, 'LizardByte/') && 42 | !github.event.release.prerelease && 43 | !github.event.release.draft 44 | needs: simplified_changelog 45 | runs-on: ubuntu-latest 46 | steps: 47 | - name: discord 48 | uses: sarisia/actions-status-discord@v1 49 | with: 50 | avatar_url: ${{ secrets.ORG_LOGO_URL }} 51 | color: 0x00ff00 52 | description: ${{ needs.simplified_changelog.outputs.SIMPLIFIED_BODY }} 53 | nodetail: true 54 | nofail: false 55 | title: ${{ github.event.repository.name }} ${{ github.ref_name }} Released 56 | url: ${{ github.event.release.html_url }} 57 | username: ${{ secrets.DISCORD_USERNAME }} 58 | webhook: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} 59 | 60 | facebook_group: 61 | if: >- 62 | startsWith(github.repository, 'LizardByte/') && 63 | !github.event.release.prerelease && 64 | !github.event.release.draft 65 | runs-on: ubuntu-latest 66 | steps: 67 | - name: facebook-post-action 68 | uses: ReenigneArcher/facebook-post-action@v1 69 | with: 70 | page_id: ${{ secrets.FACEBOOK_GROUP_ID }} 71 | access_token: ${{ secrets.FACEBOOK_ACCESS_TOKEN }} 72 | message: | 73 | ${{ github.event.repository.name }} ${{ github.ref_name }} Released 74 | url: ${{ github.event.release.html_url }} 75 | 76 | facebook_page: 77 | if: >- 78 | startsWith(github.repository, 'LizardByte/') && 79 | !github.event.release.prerelease && 80 | !github.event.release.draft 81 | runs-on: ubuntu-latest 82 | steps: 83 | - name: facebook-post-action 84 | uses: ReenigneArcher/facebook-post-action@v1 85 | with: 86 | page_id: ${{ secrets.FACEBOOK_PAGE_ID }} 87 | access_token: ${{ secrets.FACEBOOK_ACCESS_TOKEN }} 88 | message: | 89 | ${{ github.event.repository.name }} ${{ github.ref_name }} Released 90 | url: ${{ github.event.release.html_url }} 91 | 92 | reddit: 93 | if: >- 94 | startsWith(github.repository, 'LizardByte/') && 95 | !github.event.release.prerelease && 96 | !github.event.release.draft 97 | needs: simplified_changelog 98 | runs-on: ubuntu-latest 99 | steps: 100 | - name: reddit 101 | uses: bluwy/release-for-reddit-action@v2 102 | with: 103 | username: ${{ secrets.REDDIT_USERNAME }} 104 | password: ${{ secrets.REDDIT_PASSWORD }} 105 | app-id: ${{ secrets.REDDIT_CLIENT_ID }} 106 | app-secret: ${{ secrets.REDDIT_CLIENT_SECRET }} 107 | subreddit: ${{ secrets.REDDIT_SUBREDDIT }} 108 | title: ${{ github.event.repository.name }} ${{ github.ref_name }} Released 109 | url: ${{ github.event.release.html_url }} 110 | flair-id: ${{ secrets.REDDIT_FLAIR_ID }} # https://www.reddit.com/r/>/api/link_flair.json 111 | comment: ${{ needs.simplified_changelog.outputs.SIMPLIFIED_BODY }} 112 | 113 | x: 114 | if: >- 115 | startsWith(github.repository, 'LizardByte/') && 116 | !github.event.release.prerelease && 117 | !github.event.release.draft 118 | runs-on: ubuntu-latest 119 | steps: 120 | - name: x 121 | uses: nearform-actions/github-action-notify-twitter@v1 122 | with: 123 | message: ${{ github.event.release.html_url }} 124 | twitter-app-key: ${{ secrets.X_APP_KEY }} 125 | twitter-app-secret: ${{ secrets.X_APP_SECRET }} 126 | twitter-access-token: ${{ secrets.X_ACCESS_TOKEN }} 127 | twitter-access-token-secret: ${{ secrets.X_ACCESS_TOKEN_SECRET }} 128 | -------------------------------------------------------------------------------- /.github/workflows/update-changelog.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # Update changelog on release events. 7 | 8 | name: Update changelog 9 | 10 | on: 11 | release: 12 | types: [created, edited, deleted] 13 | workflow_dispatch: 14 | 15 | concurrency: 16 | group: "${{ github.workflow }}" 17 | cancel-in-progress: true 18 | 19 | jobs: 20 | update-changelog: 21 | if: >- 22 | github.event_name == 'workflow_dispatch' || 23 | (!github.event.release.prerelease && !github.event.release.draft) 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: Update Changelog 27 | uses: LizardByte/update-changelog-action@v2024.609.4705 28 | with: 29 | changelogBranch: changelog 30 | changelogFile: CHANGELOG.md 31 | token: ${{ secrets.GH_BOT_TOKEN }} 32 | -------------------------------------------------------------------------------- /.github/workflows/update-docs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # Use the `rtd` repository label to identify repositories that should trigger have this workflow. 7 | # If the project slug is not the repository name, add a repository variable named `READTHEDOCS_SLUG` with the value of 8 | # the ReadTheDocs project slug. 9 | 10 | # Update readthedocs on release events. 11 | 12 | name: Update docs 13 | 14 | on: 15 | release: 16 | types: [created, edited, deleted] 17 | 18 | concurrency: 19 | group: "${{ github.workflow }}-${{ github.event.release.tag_name }}" 20 | cancel-in-progress: true 21 | 22 | jobs: 23 | update-docs: 24 | env: 25 | RTD_SLUG: ${{ vars.READTHEDOCS_SLUG }} 26 | RTD_TOKEN: ${{ secrets.READTHEDOCS_TOKEN }} 27 | TAG: ${{ github.event.release.tag_name }} 28 | if: >- 29 | !github.event.release.draft 30 | runs-on: ubuntu-latest 31 | steps: 32 | - name: Get RTD_SLUG 33 | run: | 34 | # if the RTD_SLUG is not set, use the repository name in lowercase 35 | if [ -z "${RTD_SLUG}" ]; then 36 | RTD_SLUG=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]') 37 | fi 38 | echo "RTD_SLUG=${RTD_SLUG}" >> $GITHUB_ENV 39 | 40 | - name: Deactivate deleted release 41 | if: >- 42 | github.event_name == 'release' && 43 | github.event.action == 'deleted' 44 | run: | 45 | json_body=$(jq -n \ 46 | --arg active "false" \ 47 | --arg hidden "false" \ 48 | --arg privacy_level "public" \ 49 | '{active: $active, hidden: $hidden, privacy_level: $privacy_level}') 50 | 51 | curl \ 52 | -X PATCH \ 53 | -H "Authorization: Token ${RTD_TOKEN}" \ 54 | https://readthedocs.org/api/v3/projects/${RTD_SLUG}/versions/${TAG}/ \ 55 | -H "Content-Type: application/json" \ 56 | -d "$json_body" 57 | 58 | - name: Check if edited release is latest GitHub release 59 | id: check 60 | if: >- 61 | github.event_name == 'release' && 62 | github.event.action == 'edited' 63 | uses: actions/github-script@v7 64 | with: 65 | script: | 66 | const latestRelease = await github.rest.repos.getLatestRelease({ 67 | owner: context.repo.owner, 68 | repo: context.repo.repo 69 | }); 70 | 71 | core.setOutput('isLatestRelease', latestRelease.data.tag_name === context.payload.release.tag_name); 72 | 73 | - name: Update RTD project 74 | # changing the default branch in readthedocs makes "latest" point to that branch/tag 75 | # we can also update other properties like description, etc. 76 | if: >- 77 | steps.check.outputs.isLatestRelease == 'true' 78 | run: | 79 | json_body=$(jq -n \ 80 | --arg default_branch "${TAG}" \ 81 | --arg description "${{ github.event.repository.description }}" \ 82 | '{default_branch: $default_branch}') 83 | 84 | curl \ 85 | -X PATCH \ 86 | -H "Authorization: Token ${RTD_TOKEN}" \ 87 | https://readthedocs.org/api/v3/projects/${RTD_SLUG}/ \ 88 | -H "Content-Type: application/json" \ 89 | -d "$json_body" 90 | -------------------------------------------------------------------------------- /.github/workflows/yaml-lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This action is centrally managed in https://github.com//.github/ 3 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in 4 | # the above-mentioned repo. 5 | 6 | # Lint yaml files. 7 | 8 | name: yaml lint 9 | 10 | on: 11 | pull_request: 12 | branches: [master] 13 | types: [opened, synchronize, reopened] 14 | 15 | concurrency: 16 | group: "${{ github.workflow }}-${{ github.ref }}" 17 | cancel-in-progress: true 18 | 19 | jobs: 20 | yaml-lint: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v4 25 | 26 | - name: Find additional files 27 | id: find-files 28 | run: | 29 | # space separated list of files 30 | FILES=.clang-format 31 | 32 | # empty placeholder 33 | FOUND="" 34 | 35 | for FILE in ${FILES}; do 36 | if [ -f "$FILE" ] 37 | then 38 | FOUND="$FOUND $FILE" 39 | fi 40 | done 41 | 42 | echo "found=${FOUND}" >> $GITHUB_OUTPUT 43 | 44 | - name: yaml lint 45 | id: yaml-lint 46 | uses: ibiqlik/action-yamllint@v3 47 | with: 48 | # https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration 49 | config_data: | 50 | extends: default 51 | rules: 52 | comments: 53 | level: error 54 | line-length: 55 | max: 120 56 | truthy: 57 | # GitHub uses "on" for workflow event triggers 58 | # .clang-format file has options of "Yes" "No" that will be caught by this, so changed to "warning" 59 | allowed-values: ['true', 'false', 'on'] 60 | check-keys: true 61 | level: warning 62 | file_or_dir: . ${{ steps.find-files.outputs.found }} 63 | 64 | - name: Log 65 | run: | 66 | cat "${{ steps.yaml-lint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | .idea/ 161 | 162 | # Remove the agent Info.plist since we are building it 163 | Contents/Info.plist 164 | 165 | # Remove plexhints files 166 | plexhints-temp 167 | *cache.sqlite 168 | 169 | # Remove python modules 170 | Contents/Libraries/Shared/ 171 | 172 | # Remove plex service file cache 173 | *.pys[cod] 174 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third-party/youtube-dl"] 2 | path = third-party/youtube-dl 3 | url = https://github.com/ytdl-org/youtube-dl.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # .readthedocs.yaml 3 | # Read the Docs configuration file 4 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 5 | 6 | # Required 7 | version: 2 8 | 9 | # Set the version of Python 10 | build: 11 | os: ubuntu-20.04 12 | tools: 13 | python: "2.7" 14 | jobs: 15 | pre_build: 16 | - python ./scripts/build_plist.py 17 | post_build: 18 | - rstcheck -r . # lint rst files 19 | # - rstfmt --check --diff -w 120 . # check rst formatting 20 | 21 | # submodules required to include youtube-dl 22 | submodules: 23 | include: all 24 | recursive: true 25 | 26 | # Build documentation in the docs/ directory with Sphinx 27 | sphinx: 28 | builder: html 29 | configuration: docs/source/conf.py 30 | fail_on_warning: true 31 | 32 | # Using Sphinx, build docs in additional formats 33 | formats: all 34 | 35 | python: 36 | install: 37 | - requirements: requirements.txt # plugin requirements 38 | - requirements: requirements-dev.txt # docs requirements 39 | -------------------------------------------------------------------------------- /.rstcheck.cfg: -------------------------------------------------------------------------------- 1 | # configuration file for rstcheck, an rst linting tool 2 | # https://rstcheck.readthedocs.io/en/latest/usage/config 3 | 4 | [rstcheck] 5 | ignore_directives = 6 | automodule, 7 | include, 8 | mdinclude, 9 | todo, 10 | ignore_roles = 11 | modname, 12 | -------------------------------------------------------------------------------- /Contents/Code/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # plex debugging 4 | try: 5 | import plexhints # noqa: F401 6 | except ImportError: 7 | pass 8 | else: # the code is running outside of Plex 9 | from plexhints import plexhints_setup, update_sys_path 10 | plexhints_setup() # read the plugin plist file and determine if plexhints should use elevated policy or not 11 | update_sys_path() # when running outside plex, append the path 12 | 13 | from plexhints.decorator_kit import handler # decorator kit 14 | from plexhints.log_kit import Log # log kit 15 | from plexhints.object_kit import MessageContainer # object kit 16 | from plexhints.prefs_kit import Prefs # prefs kit 17 | 18 | # local imports 19 | from default_prefs import default_prefs 20 | 21 | 22 | def ValidatePrefs(): 23 | # type: () -> MessageContainer 24 | """ 25 | Validate plug-in preferences. 26 | 27 | This function is called when the user modifies their preferences. The developer can check the newly provided values 28 | to ensure they are correct (e.g. attempting a login to validate a username and password), and optionally return a 29 | ``MessageContainer`` to display any error information to the user. See the archived Plex documentation 30 | `Predefined functions 31 | `_ 32 | for more information. 33 | 34 | Returns 35 | ------- 36 | MessageContainer 37 | Success or Error message dependeing on results of validation. 38 | 39 | Examples 40 | -------- 41 | >>> ValidatePrefs() 42 | ... 43 | """ 44 | # todo - validate values are proper type of data, same as retroarcher 45 | # todo - validate username and password 46 | # does this ``Code`` have visibility of the ServicePrefs.json options? ... probably yes 47 | 48 | error_message = '' # start with a blank error message 49 | 50 | for key in default_prefs: 51 | try: 52 | Prefs[key] 53 | except KeyError: 54 | Log.Critical("Setting '%s' missing from 'DefaultPrefs.json'" % key) 55 | error_message += "Setting '%s' missing from 'DefaultPrefs.json'
" % key 56 | else: 57 | # test all types except 'str_' as string cannot fail 58 | if key.startswith('int_'): 59 | try: 60 | int(Prefs[key]) 61 | except ValueError: 62 | Log.Error("Setting '%s' must be an integer; Value '%s'" % (key, Prefs[key])) 63 | error_message += "Setting '%s' must be an integer; Value '%s'
" % (key, Prefs[key]) 64 | elif key.startswith('bool_'): 65 | if Prefs[key] is not True and Prefs[key] is not False: 66 | Log.Error("Setting '%s' must be True or False; Value '%s'" % (key, Prefs[key])) 67 | error_message += "Setting '%s' must be True or False; Value '%s'
" % (key, Prefs[key]) 68 | 69 | if error_message != '': 70 | return MessageContainer(header='Error', message=error_message) 71 | else: 72 | Log.Info("DefaultPrefs.json is valid") 73 | return MessageContainer(header='Success', message='RetroArcher - Provided preference values are ok') 74 | 75 | 76 | def Start(): 77 | # type: () -> None 78 | """ 79 | Start the plug-in. 80 | 81 | This function is called when the plug-in first starts. It can be used to perform extra initialisation tasks such as 82 | configuring the environment and setting default attributes. See the archived Plex documentation 83 | `Predefined functions 84 | `_ 85 | for more information. 86 | 87 | Examples 88 | -------- 89 | >>> Start() 90 | ... 91 | """ 92 | # validate prefs 93 | prefs_valid = ValidatePrefs() 94 | if prefs_valid.header == 'Error': 95 | Log.Warn('PlexyGlass plug-in preferences are not valid.') 96 | 97 | Log.Debug('PlexyGlass plug-in started.') 98 | 99 | 100 | @handler(prefix='/video/plexyglass', name='PlexyGlass', thumb='attribution.png') 101 | def main(): 102 | """ 103 | Create the main plug-in ``handler``. 104 | 105 | This is responsible for displaying the plug-in in the plug-ins menu. Since we are using the ``@handler`` decorator, 106 | and since Plex removed menu's from plug-ins, this method does not need to perform any other function. 107 | """ 108 | pass 109 | -------------------------------------------------------------------------------- /Contents/Code/default_prefs.py: -------------------------------------------------------------------------------- 1 | default_prefs = dict( 2 | str_youtube_user='', 3 | str_youtube_passwd='', 4 | ) 5 | -------------------------------------------------------------------------------- /Contents/Resources/attribution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LizardByte/PlexyGlass/35cbf6a3dab178f2ab11325e6fd5ff4a12bd48fa/Contents/Resources/attribution.png -------------------------------------------------------------------------------- /Contents/Resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LizardByte/PlexyGlass/35cbf6a3dab178f2ab11325e6fd5ff4a12bd48fa/Contents/Resources/favicon.ico -------------------------------------------------------------------------------- /Contents/Resources/icon-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LizardByte/PlexyGlass/35cbf6a3dab178f2ab11325e6fd5ff4a12bd48fa/Contents/Resources/icon-default.png -------------------------------------------------------------------------------- /Contents/Services/ServiceInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | URL 6 | 7 | YouTube 8 | 9 | TestURLs 10 | 11 | https://youtu.be/vXhmyyXFd5I 12 | https://youtube.com/watch?v=vXhmyyXFd5I 13 | https://www.youtube.com/watch?v=siOHh0uzcuY 14 | https://www.youtube.com/user/andyverg#p/a/u/0/HTGOoQNYGL4 15 | https://www.youtube.com/shemarooent#p/u/0/DP99hSszVLs 16 | https://m.youtube.com/#/watch?v=Eef-JaGhSto 17 | https://m.youtube.com/details?v=pjyfMCTAqKU 18 | https://www.youtube.com/android 19 | https://youtube.googleapis.com/v/BDjYgnUfNf4 20 | 21 | URLPatterns 22 | 23 | ^(?!.*\.{2,})(https?:)?//(www\.|m\.)?youtu(be(\.googleapis)?\.com|\.be)/(?!account(_|\?)?|artist(/|\?)|blog\?|categories\?|channels\?|charts|embed/(__videoid__|videoseries\?)|playlist\?|p/|profile\?|results\?|subscribe_widget|\?tab=).+ 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Contents/Services/URL/YouTube/ServiceCode.pys: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # standard imports 4 | from datetime import datetime 5 | from typing import Optional 6 | 7 | # plex debugging 8 | try: 9 | import plexhints # noqa: F401 10 | except ImportError: 11 | pass 12 | else: # the code is running outside of Plex 13 | from plexhints import update_sys_path 14 | update_sys_path() 15 | 16 | from plexhints.decorator_kit import indirect # decorator kit 17 | from plexhints.exception_kit import Ex # exception kit 18 | from plexhints.log_kit import Log # log kit 19 | from plexhints.model_kit import VideoClipObject # model kit 20 | from plexhints.object_kit import Callback, IndirectResponse, MediaObject, PartObject # object kit 21 | from plexhints.prefs_kit import Prefs # prefs kit 22 | 23 | # lib imports 24 | import youtube_dl 25 | 26 | # constants 27 | plugin_name = 'PlexyGlass' 28 | service_name = 'YouTube' 29 | service_type = 'URL' 30 | 31 | # todo - add more formats 32 | # determine if it's possible to add individual audio and video streams... 33 | # will plex automatically select one of each to combine them? 34 | # https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f 35 | format_dict = { 36 | 18: dict( 37 | format_note='360p', 38 | container='mp4', 39 | video_resolution=360, 40 | video_codec='h264', 41 | audio_codec='aac' 42 | ), 43 | 59: dict( 44 | format_note='480p', 45 | container='mp4', 46 | video_resolution=480, 47 | video_codec='h264', 48 | audio_codec='aac' 49 | ), 50 | 22: dict( 51 | format_note='720p', 52 | container='mp4', 53 | video_resolution=720, 54 | video_codec='h264', 55 | audio_codec='aac' 56 | ), 57 | 37: dict( 58 | format_note='1080p', 59 | container='mp4', 60 | video_resolution=1080, 61 | video_codec='h264', 62 | audio_codec='aac' 63 | ) 64 | } 65 | 66 | 67 | def extract_youtube_data(url): 68 | # type: (str) -> Optional[dict] 69 | """ 70 | Extract YouTube data from a given URL. 71 | 72 | Parameters 73 | ---------- 74 | url : str 75 | The video to extract data from. 76 | 77 | Returns 78 | ------- 79 | Optional[dict] 80 | A dictionary containing the video's data. 81 | 82 | Examples 83 | -------- 84 | >>> extract_youtube_data(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ') 85 | {...} 86 | """ 87 | youtube_dl_params = dict( 88 | outmpl='%(id)s.%(ext)s', 89 | youtube_include_dash_manifest=False, 90 | username=Prefs['str_youtube_user'] if Prefs['str_youtube_user'] else None, 91 | password=Prefs['str_youtube_passwd'] if Prefs['str_youtube_passwd'] else None, 92 | ) 93 | 94 | ydl = youtube_dl.YoutubeDL(params=youtube_dl_params) 95 | 96 | with ydl: 97 | try: 98 | result = ydl.extract_info( 99 | url=url, 100 | download=False # We just want to extract the info 101 | ) 102 | except youtube_dl.utils.ExtractorError as e: 103 | Log.Error('%s :: %s %s Service :: error: %s' % (plugin_name, service_name, service_type, e)) 104 | raise Ex.MediaNotAvailable 105 | except youtube_dl.utils.DownloadError as e: 106 | if 'Sign in to confirm your age' in str(e): 107 | Log.Error('%s :: %s %s Service :: error: %s' % (plugin_name, service_name, service_type, e)) 108 | raise Ex.MediaNotAuthorized 109 | elif 'The uploader has not made this video available in your country.' in str(e): 110 | Log.Error('%s :: %s %s Service :: error: %s' % (plugin_name, service_name, service_type, e)) 111 | raise Ex.MediaGeoblocked 112 | else: 113 | if 'entries' in result: 114 | # Can be a playlist or a list of videos 115 | video_data = result['entries'][0] 116 | else: 117 | # Just a video 118 | video_data = result 119 | 120 | return video_data 121 | 122 | return 123 | 124 | 125 | def NormalizeURL(url): 126 | # type: (str) -> Optional[str] 127 | """ 128 | Get the video webpage url from `youtube-dl`. 129 | 130 | Parameters 131 | ---------- 132 | url : str 133 | A string representation of url as provided by the Plex plugin. 134 | 135 | Returns 136 | ------- 137 | Optional[str] 138 | The video webpage url. If no video webpage is found then ``None`` is returned. 139 | 140 | Examples 141 | -------- 142 | >>> NormalizeURL(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ') 143 | 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' 144 | """ 145 | Log.Info('%s :: %s %s Service :: normalizing url: %s' % (plugin_name, service_name, service_type, url)) 146 | 147 | video_data = extract_youtube_data(url=url) 148 | 149 | if video_data: 150 | try: 151 | webpage_url = video_data['webpage_url'] 152 | Log.Error('%s :: %s %s Service :: normalized url to: %s' % ( 153 | plugin_name, service_name, service_type, webpage_url)) 154 | except KeyError: 155 | Log.Error('%s :: %s %s Service :: webpage_url not found in video_data: %s' % ( 156 | plugin_name, service_name, service_type, video_data)) 157 | return 158 | else: 159 | return webpage_url 160 | 161 | 162 | def MetadataObjectForURL(url): 163 | # type: (str) -> Optional[VideoClipObject] 164 | """ 165 | Get YouTube metadata for a given URL. 166 | 167 | Parameters 168 | ---------- 169 | url : str 170 | The url to get metadata for. 171 | 172 | Returns 173 | ------- 174 | Optional[VideoClipObject] 175 | The Plex video clip object. 176 | 177 | Examples 178 | -------- 179 | >>> MetadataObjectForURL(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ') 180 | ... 181 | """ 182 | Log.Info('%s :: %s %s Service :: collecting metadata for url: %s' % (plugin_name, service_name, service_type, url)) 183 | 184 | video_data = extract_youtube_data(url=url) 185 | 186 | title = None 187 | summary = None 188 | thumb = None 189 | date = None 190 | duration = 0 191 | 192 | if video_data: 193 | try: 194 | title = video_data['title'] 195 | except KeyError: 196 | raise Ex.MediaNotAvailable 197 | 198 | if not title: 199 | raise Ex.MediaNotAvailable 200 | 201 | try: 202 | summary = video_data['description'] 203 | except KeyError: 204 | pass 205 | 206 | try: 207 | thumb = video_data['thumbnail'] 208 | except KeyError: 209 | thumb_height = 0 210 | try: 211 | for thumbs in video_data['thumbnails']: 212 | if thumbs['height'] > thumb_height: 213 | thumb = thumbs['url'] 214 | thumb_height = thumbs['height'] 215 | except KeyError: 216 | pass 217 | 218 | try: 219 | date = video_data['upload_date'] 220 | except KeyError: 221 | pass 222 | else: 223 | date = datetime.strptime(date, '%Y%m%d') 224 | 225 | try: 226 | duration = video_data['duration'] # in seconds 227 | except KeyError: 228 | pass 229 | else: 230 | # duration must be in milliseconds 231 | duration *= 1000 232 | 233 | Log.Info('%s :: %s %s Service :: title: %s' % (plugin_name, service_name, service_type, title)) 234 | Log.Info('%s :: %s %s Service :: summary: %s' % (plugin_name, service_name, service_type, summary)) 235 | Log.Info('%s :: %s %s Service :: originally_available_at: %s' % (plugin_name, service_name, service_type, date)) 236 | Log.Info('%s :: %s %s Service :: duration: %s' % (plugin_name, service_name, service_type, duration)) 237 | 238 | return VideoClipObject( 239 | title=title, 240 | summary=summary, 241 | thumb=thumb, 242 | originally_available_at=date, 243 | duration=duration 244 | ) 245 | 246 | 247 | def MediaObjectsForURL(url): 248 | # type: (str) -> Optional[list] 249 | """ 250 | Build the Plex media objects for a given URL. 251 | 252 | Parameters 253 | ---------- 254 | url : str 255 | The url to build media objects for. 256 | 257 | Returns 258 | ------- 259 | Optional[list] 260 | A list of Plex media objects. 261 | 262 | Examples 263 | -------- 264 | >>> MediaObjectsForURL(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ') 265 | [...] 266 | """ 267 | Log.Info('%s :: %s %s Service :: attempting to create media object for url: %s' % ( 268 | plugin_name, service_name, service_type, url)) 269 | video_data = extract_youtube_data(url=url) 270 | 271 | ret = [] 272 | 273 | if video_data: 274 | 275 | for fmt in video_data['formats']: 276 | fmt_id = int(fmt['format_id']) # youtube-dl gives unicode values 277 | if fmt_id in format_dict: # item has video and audio! 278 | Log.Info('%s :: %s %s Service :: found matching format id: %s' % ( 279 | plugin_name, service_name, service_type, fmt_id)) 280 | ret.append(MediaObject( 281 | parts=[ 282 | PartObject( 283 | key=Callback( 284 | play_video, url=url, post_url=url, default_fmt=fmt_id) 285 | ) 286 | ], 287 | container=format_dict[fmt_id]['container'], 288 | video_codec=format_dict[fmt_id]['video_codec'], 289 | audio_codec=format_dict[fmt_id]['audio_codec'], 290 | video_resolution=str(format_dict[fmt_id]['video_resolution']), 291 | optimized_for_streaming=(format_dict[fmt_id]['container'] == 'mp4') 292 | )) 293 | 294 | return ret 295 | 296 | 297 | @indirect 298 | def play_video(url=None, default_fmt=None, **kwargs): 299 | # type: (Optional[str], Optional[int], **any) -> Optional[IndirectResponse] 300 | """ 301 | Play the YouTube video of a given url and format. 302 | 303 | Parameters 304 | ---------- 305 | url : Optional[str] 306 | The url of the video to play. If not url is given the function will immediately return. 307 | default_fmt : Optional[int] 308 | The YouTube format id to attempt to play. 309 | kwargs : **any 310 | Not currently used. 311 | 312 | Returns 313 | ------- 314 | Optional[IndirectResponse] 315 | The playback response for Plex to process. 316 | 317 | Examples 318 | -------- 319 | >>> play_video(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ', default_fmt=37) 320 | ... 321 | """ 322 | Log.Info('%s :: %s %s Service :: attempting to play video: %s' % (plugin_name, service_name, service_type, url)) 323 | 324 | if not url: 325 | return None 326 | 327 | video_data = extract_youtube_data(url=url) 328 | 329 | if video_data: 330 | for fmt in video_data['formats']: 331 | fmt_id = int(fmt['format_id']) # youtube-dl gives unicode values 332 | if fmt_id == default_fmt: 333 | final_url = fmt['url'] 334 | Log.Info('%s :: %s %s Service :: final_url: %s' % (plugin_name, service_name, service_type, final_url)) 335 | 336 | return IndirectResponse(VideoClipObject, key=final_url) 337 | 338 | return 339 | -------------------------------------------------------------------------------- /Contents/Services/URL/YouTube/ServicePrefs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "str_youtube_user", 4 | "type": "text", 5 | "label": "str_youtube_user", 6 | "default": "", 7 | "secure": "true" 8 | }, 9 | { 10 | "id": "str_youtube_passwd", 11 | "type": "text", 12 | "label": "str_youtube_passwd", 13 | "default": "", 14 | "option": "hidden", 15 | "secure": "true" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /Contents/Strings/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "YouTube-Passwort", 3 | "str_youtube_user": "YouTube-Benutzername" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/en-gb.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "YouTube Password", 3 | "str_youtube_user": "YouTube Username" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/en-us.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "YouTube Password", 3 | "str_youtube_user": "YouTube Username" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "YouTube Password", 3 | "str_youtube_user": "YouTube Username" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/es.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "Contraseña de YouTube", 3 | "str_youtube_user": "Usuario de YouTube" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "Mot de passe YouTube", 3 | "str_youtube_user": "Nom d'utilisateur YouTube" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/it.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "Password di YouTube", 3 | "str_youtube_user": "Nome Utente YouTube" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/ja.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "YouTube のパスワード", 3 | "str_youtube_user": "YouTubeユーザー名" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/pt.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "Senha do YouTube", 3 | "str_youtube_user": "Usuário do YouTube" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "Пароль YouTube", 3 | "str_youtube_user": "Имя пользователя YouTube" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/sv.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "YouTube lösenord", 3 | "str_youtube_user": "YouTube Användarnamn" 4 | } 5 | -------------------------------------------------------------------------------- /Contents/Strings/zh.json: -------------------------------------------------------------------------------- 1 | { 2 | "str_youtube_passwd": "YouTube 密码", 3 | "str_youtube_user": "YouTube 用户名" 4 | } 5 | -------------------------------------------------------------------------------- /DOCKER_README.md: -------------------------------------------------------------------------------- 1 | ### lizardbyte/plexyglass 2 | 3 | > **Attention**: Plex is removing ALL support for plugins. This project is no longer maintained. 4 | > See [Plex Forum](https://forums.plex.tv/t/important-information-for-users-running-plex-media-server-on-nvidia-shield-devices/883484) 5 | > for more information. 6 | 7 | This is a [docker-mod](https://linuxserver.github.io/docker-mods/) for 8 | [plex](https://hub.docker.com/r/linuxserver/plex) which adds [PlexyGlass](https://github.com/LizardByte/PlexyGlass) 9 | to plex as a plugin, to be downloaded/updated during container start. 10 | 11 | This image extends the plex image, and is not intended to be created as a separate container. 12 | 13 | ### Installation 14 | 15 | In plex docker arguments, set an environment variable `DOCKER_MODS=lizardbyte/plexyglass:latest` or 16 | `DOCKER_MODS=ghcr.io/lizardbyte/plexyglass:latest` 17 | 18 | If adding multiple mods, enter them in an array separated by `|`, such as 19 | `DOCKER_MODS=lizardbyte/plexyglass:latest|linuxserver/mods:other-plex-mod` 20 | 21 | ### Supported Architectures 22 | 23 | Specifying `lizardbyte/plexyglass:latest` or `ghcr.io/lizardbyte/plexyglass:latest` should retrieve the correct image 24 | for your architecture. 25 | 26 | The architectures supported by this image are: 27 | 28 | | Architecture | Available | 29 | |:------------:|:---------:| 30 | | x86-64 | ✅ | 31 | | arm64 | ✅ | 32 | | armhf | ✅ | 33 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.4 2 | # artifacts: false 3 | # platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 4 | FROM ubuntu:22.04 AS buildstage 5 | 6 | # build args 7 | ARG BUILD_VERSION 8 | ARG COMMIT 9 | ARG GITHUB_SHA=$COMMIT 10 | # note: BUILD_VERSION may be blank, COMMIT is also available 11 | # note: build_plist.py uses BUILD_VERSION and GITHUB_SHA 12 | 13 | SHELL ["/bin/bash", "-o", "pipefail", "-c"] 14 | # install dependencies 15 | RUN <<_DEPS 16 | #!/bin/bash 17 | set -e 18 | apt-get update -y 19 | apt-get install -y --no-install-recommends \ 20 | patch \ 21 | python2=2.7.18* \ 22 | python-pip=20.3.4* 23 | apt-get clean 24 | rm -rf /var/lib/apt/lists/* 25 | _DEPS 26 | 27 | # create build dir and copy GitHub repo there 28 | COPY --link . /build 29 | 30 | # set build dir 31 | WORKDIR /build 32 | 33 | # update pip 34 | RUN <<_PIP 35 | #!/bin/bash 36 | set -e 37 | python2 -m pip --no-python-version-warning --disable-pip-version-check install --no-cache-dir --upgrade \ 38 | pip setuptools 39 | # dev requirements not necessary for docker image, significantly speeds up build since lxml doesn't need to build 40 | _PIP 41 | 42 | # build plugin 43 | RUN <<_BUILD 44 | #!/bin/bash 45 | set -e 46 | python2 -m pip --no-python-version-warning --disable-pip-version-check install --no-cache-dir --upgrade \ 47 | --target=./Contents/Libraries/Shared -r requirements.txt --no-warn-script-location 48 | python2 ./scripts/build_plist.py 49 | _BUILD 50 | 51 | ## patch youtube-dl, cannot use git apply because we don't pass in any git files 52 | #WORKDIR /build/Contents/Libraries/Shared 53 | #RUN <<_PATCH 54 | ##!/bin/bash 55 | #set -e 56 | #patch_dir=/build/patches 57 | #patch -p1 < "${patch_dir}/youtube_dl-compat.patch" 58 | #_PATCH 59 | 60 | WORKDIR /build 61 | 62 | # clean 63 | RUN <<_CLEAN 64 | #!/bin/bash 65 | set -e 66 | rm -rf ./scripts/ 67 | # list contents 68 | ls -a 69 | _CLEAN 70 | 71 | FROM scratch AS deploy 72 | 73 | # variables 74 | ARG PLUGIN_NAME="PlexyGlass.bundle" 75 | ARG PLUGIN_DIR="/config/Library/Application Support/Plex Media Server/Plug-ins" 76 | 77 | # add files from buildstage 78 | COPY --link --from=buildstage /build/ $PLUGIN_DIR/$PLUGIN_NAME 79 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/README.rst 2 | 3 | Overview 4 | ======== 5 | 6 | .. attention:: 7 | 8 | Plex is removing ALL support for plugins. This project is no longer maintained. See 9 | `Plex Forum `__ 10 | for more information. 11 | 12 | LizardByte has the full documentation hosted on `Read the Docs `__. 13 | 14 | About 15 | ----- 16 | PlexyGlass is a Services plug-in for Plex Media Server. The plug-in currently provides a YouTube URL Service. 17 | Additional services may be added in the future. 18 | 19 | Integrations 20 | ------------ 21 | 22 | .. image:: https://img.shields.io/github/actions/workflow/status/lizardbyte/plexyglass/CI.yml.svg?branch=master&label=CI%20build&logo=github&style=for-the-badge 23 | :alt: GitHub Workflow Status (CI) 24 | :target: https://github.com/LizardByte/PlexyGlass/actions/workflows/CI.yml?query=branch%3Amaster 25 | 26 | .. image:: https://img.shields.io/readthedocs/plexyglass?label=Docs&style=for-the-badge&logo=readthedocs 27 | :alt: Read the Docs 28 | :target: http://plexyglass.readthedocs.io/ 29 | 30 | .. image:: https://img.shields.io/codecov/c/gh/LizardByte/PlexyGlass?token=X8WDZVM33W&style=for-the-badge&logo=codecov&label=codecov 31 | :alt: Codecov 32 | :target: https://codecov.io/gh/LizardByte/PlexyGlass 33 | 34 | Downloads 35 | --------- 36 | 37 | .. image:: https://img.shields.io/github/downloads/lizardbyte/plexyglass/total?style=for-the-badge&logo=github 38 | :alt: GitHub Releases 39 | :target: https://github.com/LizardByte/PlexyGlass/releases/latest 40 | 41 | .. image:: https://img.shields.io/docker/pulls/lizardbyte/plexyglass?style=for-the-badge&logo=docker 42 | :alt: Docker 43 | :target: https://hub.docker.com/r/lizardbyte/plexyglass 44 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | --- 2 | codecov: 3 | branch: master 4 | 5 | coverage: 6 | status: 7 | project: 8 | default: 9 | target: auto 10 | threshold: 10% 11 | 12 | comment: 13 | layout: "diff, flags, files" 14 | behavior: default 15 | require_changes: false # if true: only post the comment if coverage changes 16 | -------------------------------------------------------------------------------- /crowdin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | "base_path": "." 3 | "base_url": "https://api.crowdin.com" # optional (for Crowdin Enterprise only) 4 | "preserve_hierarchy": true # false will flatten tree on crowdin, but doesn't work with dest option 5 | "pull_request_labels": [ 6 | "crowdin", 7 | "l10n" 8 | ] 9 | 10 | "files": [ 11 | { 12 | "source": "/Contents/Strings/en.json", 13 | "dest": "/plexyglass.json", 14 | "translation": "/Contents/Strings/%two_letters_code%.%file_extension%", 15 | "languages_mapping": { 16 | "two_letters_code": { 17 | # map non-two letter codes here, left side is crowdin designation, right side is plex designation 18 | "en-GB": "en-gb", 19 | "en-US": "en-us" 20 | } 21 | }, 22 | "update_option": "update_as_unapproved" 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= -W --keep-going 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | set "SPHINXOPTS=-W --keep-going" 13 | 14 | %SPHINXBUILD% >NUL 2>NUL 15 | if errorlevel 9009 ( 16 | echo. 17 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 18 | echo.installed, then set the SPHINXBUILD environment variable to point 19 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 20 | echo.may add the Sphinx directory to PATH. 21 | echo. 22 | echo.If you don't have Sphinx installed, grab it from 23 | echo.https://www.sphinx-doc.org/ 24 | exit /b 1 25 | ) 26 | 27 | if "%1" == "" goto help 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% || exit /b %ERRORLEVEL% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% || exit /b %ERRORLEVEL% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /docs/source/about/changelog.rst: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | .. only:: epub 5 | 6 | You can view the changelog in the 7 | `online version `__. 8 | 9 | .. only:: html 10 | 11 | .. raw:: html 12 | 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /docs/source/about/docker.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/DOCKER_README.md 2 | 3 | Docker 4 | ------ 5 | 6 | .. mdinclude:: ../../../DOCKER_README.md 7 | -------------------------------------------------------------------------------- /docs/source/about/installation.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/docs/source/about/installation.rst 2 | 3 | Installation 4 | ============ 5 | The recommended method for running PlexyGlass is to use the `bundle`_ in the `latest release`_. 6 | 7 | Bundle 8 | ------ 9 | The bundle is cross platform, meaning Linux, macOS, and Windows are supported. 10 | 11 | #. Download the ``plexyglass.bundle.zip`` from the `latest release`_ 12 | #. Extract the contents to your Plex Media Server Plugins directory. 13 | 14 | .. Tip:: See 15 | `How do I find the Plug-Ins folder `__ 16 | for information specific to your Plex server install. 17 | 18 | Docker 19 | ------ 20 | Docker images are available on `Dockerhub`_ and `ghcr.io`_. 21 | 22 | See :ref:`Docker ` for additional information. 23 | 24 | Source 25 | ------ 26 | .. Caution:: Installing from source is not recommended most users. 27 | 28 | #. Follow the steps in :ref:`Build `. 29 | #. Move the compiled ``PlexyGlass.bundle`` to your Plex Media Server Plugins directory. 30 | 31 | .. _latest release: https://github.com/LizardByte/PlexyGlass/releases/latest 32 | .. _Dockerhub: https://hub.docker.com/repository/docker/lizardbyte/plexyglass 33 | .. _ghcr.io: https://github.com/orgs/LizardByte/packages?repo_name=plexyglass 34 | -------------------------------------------------------------------------------- /docs/source/about/overview.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../../README.rst -------------------------------------------------------------------------------- /docs/source/about/usage.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/docs/source/about/usage.rst 2 | 3 | Usage 4 | ===== 5 | 6 | End Users 7 | --------- 8 | Minimal setup is required to use PlexyGlass. In addition to the installation, a couple of settings may be configured. 9 | 10 | #. Navigate to the `Plugins` menu within the Plex server settings. 11 | #. Select the gear cog when hovering over the PlexyGlass plugin tile. 12 | #. Set the values of the preferences and save. 13 | 14 | .. Warning:: Plex stores configuration values in the log. If you upload your logs for support, it would be wise to 15 | review the data in the log file. 16 | 17 | Developers 18 | ---------- 19 | This section is intended for developers utilizing the plugin to support URL services or the like. 20 | 21 | It is very easy to use the URL service in your metadata agent. Below is an example. 22 | 23 | .. code-block:: python 24 | 25 | video_title='Rick Astley - Never Gonna Give You Up (Official Music Video)' 26 | video_url='https://www.youtube.com/watch?v=dQw4w9WgXcQ' 27 | 28 | metadata.extras.add(OtherObject(title=video_title, url=video_url)) 29 | 30 | You can pass in many other parameters if you'd like, but they are all optional except the url. Below is a bare 31 | minimal example. 32 | 33 | .. code-block:: python 34 | 35 | video_url='https://www.youtube.com/watch?v=dQw4w9WgXcQ' 36 | 37 | metadata.extras.add(OtherObject(url=video_url)) 38 | 39 | .. Tip:: For help with metadata agent or general plug-in development, check out our 40 | `plexhints `__ python library. 41 | -------------------------------------------------------------------------------- /docs/source/code_docs/main.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/Contents/Code/__init__.py 2 | 3 | .. include:: ../global.rst 4 | 5 | :modname:`__init__` 6 | ------------------------ 7 | .. automodule:: Code 8 | :members: 9 | :show-inheritance: 10 | -------------------------------------------------------------------------------- /docs/source/code_docs/youtube.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/Contents/Services/URL/YouTube/ServiceCode.pys 2 | 3 | .. include:: ../global.rst 4 | 5 | :modname:`YouTube` 6 | ------------------------ 7 | .. automodule:: YouTube 8 | :members: 9 | :show-inheritance: 10 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # standard imports 8 | from datetime import datetime 9 | import os 10 | import shutil 11 | import sys 12 | 13 | try: 14 | import pathlib2 as pathlib 15 | except ImportError: 16 | import pathlib 17 | 18 | 19 | # -- Path setup -------------------------------------------------------------- 20 | 21 | # If extensions (or modules to document with autodoc) are in another directory, 22 | # add these directories to sys.path here. If the directory is relative to the 23 | # documentation root, use os.path.abspath to make it absolute, like shown here. 24 | 25 | script_dir = os.path.dirname(os.path.abspath(__file__)) # the directory of this file 26 | source_dir = os.path.dirname(script_dir) # the source folder directory 27 | root_dir = os.path.dirname(source_dir) # the root folder directory 28 | 29 | # destination for copies of services 30 | service_destination_directory = os.path.join(source_dir, 'build', 'service_modules') 31 | service_destination_path = pathlib.Path(service_destination_directory) 32 | service_destination_path.mkdir(parents=True, exist_ok=True) 33 | 34 | 35 | paths = [ 36 | os.path.join(root_dir, 'Contents', 'Libraries', 'Shared'), # location of plugin dependencies 37 | os.path.join(root_dir, 'Contents'), # location of "Code" module, aka the Plugin 38 | service_destination_directory, # location of copied service files 39 | ] 40 | 41 | # Copy ServiceCode files to python modules 42 | services_dir = os.path.join(root_dir, 'Contents', 'Services') 43 | 44 | services = dict( 45 | URL=[ 46 | 'YouTube' 47 | ] 48 | ) 49 | 50 | for service_type in services: 51 | for service in services[service_type]: 52 | service_file = os.path.join(services_dir, service_type, service, 'ServiceCode.pys') 53 | print(service_file) 54 | 55 | if os.path.isfile(service_file): 56 | shutil.copy(service_file, os.path.join(service_destination_directory, '%s.py' % service)) 57 | 58 | for directory in paths: 59 | sys.path.insert(0, directory) 60 | 61 | # -- Project information ----------------------------------------------------- 62 | project = 'PlexyGlass' 63 | project_copyright = '%s, %s' % (datetime.now().year, project) 64 | epub_copyright = project_copyright 65 | author = 'ReenigneArcher' 66 | 67 | # The full version, including alpha/beta/rc tags 68 | # https://docs.readthedocs.io/en/stable/reference/environment-variables.html#envvar-READTHEDOCS_VERSION 69 | version = os.getenv('READTHEDOCS_VERSION', 'dirty') 70 | 71 | 72 | # -- General configuration --------------------------------------------------- 73 | 74 | # Add any Sphinx extension module names here, as strings. They can be 75 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 76 | # ones. 77 | extensions = [ 78 | 'm2r2', # enable markdown files 79 | 'numpydoc', # this automatically loads `sphinx.ext.autosummary` as well 80 | 'sphinx.ext.autodoc', # autodocument modules 81 | 'sphinx.ext.autosectionlabel', 82 | 'sphinx.ext.todo', # enable to-do sections 83 | 'sphinx.ext.viewcode' # add links to view source code 84 | ] 85 | 86 | # Add any paths that contain templates here, relative to this directory. 87 | # templates_path = ['_templates'] 88 | 89 | # List of patterns, relative to source directory, that match files and 90 | # directories to ignore when looking for source files. 91 | # This pattern also affects html_static_path and html_extra_path. 92 | exclude_patterns = ['toc.rst'] 93 | 94 | # Extensions to include. 95 | source_suffix = ['.rst', '.md'] 96 | 97 | # Change default contents file 98 | master_doc = 'index' 99 | 100 | # -- Options for HTML output ------------------------------------------------- 101 | 102 | # images 103 | html_favicon = os.path.join(root_dir, 'Contents', 'Resources', 'favicon.ico') 104 | html_logo = os.path.join(root_dir, 'Contents', 'Resources', 'attribution.png') 105 | 106 | # Add any paths that contain custom static files (such as style sheets) here, 107 | # relative to this directory. They are copied after the builtin static files, 108 | # so a file named "default.css" will overwrite the builtin "default.css". 109 | # html_static_path = ['_static'] 110 | 111 | # These paths are either relative to html_static_path 112 | # or fully qualified paths (eg. https://...) 113 | # html_css_files = [ 114 | # 'css/custom.css', 115 | # ] 116 | # html_js_files = [ 117 | # 'js/custom.js', 118 | # ] 119 | 120 | # The theme to use for HTML and HTML Help pages. See the documentation for 121 | # a list of builtin themes. 122 | html_theme = 'sphinx_rtd_theme' 123 | 124 | html_theme_options = { 125 | 'analytics_id': 'G-SSW90X5YZX', # Provided by Google in your dashboard 126 | 'analytics_anonymize_ip': False, 127 | 'logo_only': False, 128 | 'display_version': True, 129 | 'prev_next_buttons_location': 'bottom', 130 | 'style_external_links': True, 131 | 'vcs_pageview_mode': 'blob', 132 | 'style_nav_header_background': '#151515', 133 | # Toc options 134 | 'collapse_navigation': True, 135 | 'sticky_navigation': True, 136 | 'navigation_depth': 4, 137 | 'includehidden': True, 138 | 'titles_only': False, 139 | } 140 | 141 | # extension config options 142 | autodoc_preserve_defaults = True # Do not evaluate default arguments of functions 143 | autosectionlabel_prefix_document = True # Make sure the target is unique 144 | todo_include_todos = True 145 | 146 | # numpydoc config 147 | numpydoc_validation_checks = {'all', 'SA01'} # Report warnings for all checks *except* for SA01 148 | 149 | # disable epub mimetype warnings 150 | # https://github.com/readthedocs/readthedocs.org/blob/eadf6ac6dc6abc760a91e1cb147cc3c5f37d1ea8/docs/conf.py#L235-L236 151 | suppress_warnings = ["epub.unknown_project_files"] 152 | -------------------------------------------------------------------------------- /docs/source/contributing/build.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/docs/source/contributing/build.rst 2 | 3 | Build 4 | ===== 5 | Compiling PlexyGlass is fairly simple; however it is recommended to use Python 2.7 since the Plex framework is using 6 | Python 2.7. 7 | 8 | Clone 9 | ----- 10 | Ensure `git `__ is installed and run the following: 11 | 12 | .. code-block:: bash 13 | 14 | git clone --recurse-submodules https://github.com/lizardbyte/plexyglass.git plexyglass.bundle 15 | cd ./plexyglass.bundle 16 | 17 | Setup venv 18 | ---------- 19 | It is recommended to setup and activate a `venv`_. 20 | 21 | .. Apply Patches 22 | .. ------------- 23 | .. Patch YouTube-DL 24 | .. .. code-block:: bash 25 | .. 26 | .. pushd ./third-party/youtube-dl 27 | .. git apply -v ../../patches/youtube_dl-compat.patch 28 | .. popd 29 | 30 | Install Requirements 31 | -------------------- 32 | Install Requirements 33 | .. code-block:: bash 34 | 35 | python -m pip install --upgrade --target=./Contents/Libraries/Shared -r requirements.txt --no-warn-script-location 36 | 37 | Development Requirements 38 | .. code-block:: bash 39 | 40 | python -m pip install -r requirements-dev.txt 41 | 42 | Build Plist 43 | ----------- 44 | .. code-block:: bash 45 | 46 | python ./scripts/build_plist.py 47 | 48 | Remote Build 49 | ------------ 50 | It may be beneficial to build remotely in some cases. This will enable easier building on different operating systems. 51 | 52 | #. Fork the project 53 | #. Activate workflows 54 | #. Trigger the `CI` workflow manually 55 | #. Download the artifacts from the workflow run summary 56 | 57 | .. _venv: https://docs.python.org/3/library/venv.html 58 | -------------------------------------------------------------------------------- /docs/source/contributing/contributing.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/docs/source/contributing/contributing.rst 2 | 3 | Contributing 4 | ============ 5 | 6 | Read our contribution guide in our organization level 7 | `docs `__. 8 | -------------------------------------------------------------------------------- /docs/source/contributing/testing.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/docs/source/contributing/testing.rst 2 | 3 | Testing 4 | ======= 5 | 6 | Flake8 7 | ------ 8 | PlexyGlass uses `Flake8 `__ for enforcing consistent code styling. Flake is included 9 | in the ``requirements-dev.txt``. 10 | 11 | The config file for flake8 is ``.flake8``. This is already included in the root of the repo and should not be modified. 12 | 13 | Test with Flake8 14 | .. code-block:: bash 15 | 16 | python -m flake8 17 | 18 | Sphinx 19 | ------ 20 | PlexyGlass uses `Sphinx `__ for documentation building. Sphinx is included 21 | in the ``requirements-dev.txt``. 22 | 23 | PlexyGlass follows `numpydoc `__ styling and formatting in 24 | docstrings. This will be tested when building the docs. `numpydoc` is included in the ``requirements-dev.txt``. 25 | 26 | The config file for Sphinx is ``docs/source/conf.py``. This is already included in the root of the repo and should not 27 | be modified. 28 | 29 | Test with Sphinx 30 | .. code-block:: bash 31 | 32 | cd docs 33 | make html 34 | 35 | Alternatively 36 | 37 | .. code-block:: bash 38 | 39 | cd docs 40 | sphinx-build -b html source build 41 | 42 | pytest 43 | ------ 44 | PlexyGlass uses `pytest `__ for unit testing. pytest is included in the 45 | ``requirements-dev.txt``. 46 | 47 | No config is required for pytest. 48 | 49 | Test with pytest 50 | .. code-block:: bash 51 | 52 | python -m pytest 53 | -------------------------------------------------------------------------------- /docs/source/global.rst: -------------------------------------------------------------------------------- 1 | .. role:: modname 2 | :class: modname 3 | 4 | .. role:: title 5 | :class: title 6 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/LizardByte/PlexyGlass/blob/master/docs/source/index.rst 2 | 3 | Table of Contents 4 | ================= 5 | .. include:: toc.rst 6 | -------------------------------------------------------------------------------- /docs/source/toc.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | :caption: About 4 | 5 | about/overview 6 | about/installation 7 | about/docker 8 | about/usage 9 | about/changelog 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | :caption: Contributing 14 | 15 | contributing/contributing 16 | contributing/build 17 | contributing/testing 18 | 19 | .. toctree:: 20 | :maxdepth: 0 21 | :caption: Plugin Code 22 | :titlesonly: 23 | 24 | code_docs/main 25 | 26 | .. toctree:: 27 | :maxdepth: 0 28 | :caption: URL Services Code 29 | :titlesonly: 30 | 31 | code_docs/youtube 32 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | # development environment requirements, these should not be distributed 2 | flake8==3.9.2;python_version<"3" 3 | m2r2==0.3.2;python_version<"3" 4 | numpydoc==0.9.2;python_version<"3" 5 | pathlib2==2.3.7.post1;python_version<"3" 6 | plexhints==2023.1210.163618 # type hinting library for plex development 7 | pytest==4.6.11;python_version<"3" 8 | pytest-cov==2.12.1;python_version<"3" 9 | rstcheck==3.5.0;python_version<"3" 10 | Sphinx==1.8.6;python_version<"3" 11 | sphinx-rtd-theme==1.1.1;python_version<"3" 12 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # these requirements must support python 2.7 2 | # it is doubtful that Plex will ever update to Python 3+ 3 | typing==3.10.0.0 4 | 5 | # youtube_dl is not capable or willing to create a new release so have to install from git 6 | # youtube_dl==2021.12.17 7 | ./third-party/youtube-dl 8 | -------------------------------------------------------------------------------- /scripts/build_plist.py: -------------------------------------------------------------------------------- 1 | import os 2 | import plistlib 3 | 4 | version = os.getenv('BUILD_VERSION', None) 5 | print('version: %s' % version) 6 | 7 | commit = os.getenv('GITHUB_SHA', 'development build') 8 | print('commit: %s' % commit) 9 | 10 | if not version: 11 | checked = '' 12 | if commit != 'development build': 13 | version = commit[0:7] 14 | print('using commit as version: %s' % version) 15 | else: 16 | version = commit 17 | print('unknown version: %s' % version) 18 | else: 19 | checked = '' 20 | 21 | info_file = os.path.join('Contents', 'Info.plist') 22 | 23 | pl = dict( 24 | CFBundleIdentifier='dev.lizardbyte.plexyglass', 25 | PlexAgentAttributionText=""" 26 | 28 | 31 | 36 | 37 |
38 | PlexyGlass
39 |
40 |
41 | A plugin by LizardByte that provides updated 42 | URL services. URL services allow indirect playback of extra metadata items, such as trailers, interviews, 43 | etc. The following services are provided.
44 |
45 | 46 | YouTube 47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 56 | 57 |
Version: %s%s| Releases
58 |
59 | 60 | 61 | 62 | 64 | 65 |
Reference:| Docs
66 | ]]> 67 | """ % (checked, version), 68 | CFBundleDevelopmentRegion='English', 69 | CFBundleExecutable='', 70 | CFBundlePackageType='AAPL', 71 | CFBundleSignature='hook', 72 | PlexFrameworkVersion='2', 73 | PlexClientPlatforms='*', 74 | PlexClientPlatformExclusions='', 75 | PlexPluginClass='Resource', 76 | PlexPluginCodePolicy='Elevated', 77 | PlexPluginConsoleLogging='0', 78 | PlexPluginDebug='1', 79 | PlexPluginMode='Daemon', 80 | PlexPluginRegions=[''], 81 | PlexBundleVersion=version, 82 | PlexShortBundleVersion=version, 83 | ) 84 | 85 | # PlexPluginMode: 86 | # This one does nothing with a value of "Always On", a value of "daemon" keeps the plugin alive in the background. 87 | 88 | # PlexClientPlatforms and PlexClientPlatformExclusions: 89 | # Any Clients support or not supported by the plugin. 90 | # Possible values are * for all platforms, MacOSX, Windows, Linux, Roku, Android, iOS, Safari, Firefox, Chrome, LGTV, \ 91 | # Samsung, PlexConnect and Plex Home Theater 92 | 93 | # PlexPluginRegions: 94 | # Possible string values are the proper ISO two letter code for the country. 95 | # A full list of values are available at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 96 | 97 | # PlexPluginDebug: 98 | # Possible values are 0 and 1. Setting it to "1" rather than "0" turns on debug logging 99 | 100 | # PlexPluginCodePolicy: 101 | # This allows channels to access some python methods which are otherwise blocked, as well as import external code \ 102 | # libraries, and interact with the PMS HTTP API 103 | 104 | # PlexPluginClass: 105 | # This key is used to show that the plugin is an agent. possible values are 'Agent' and 'Resource' 106 | 107 | # PlexPluginConsoleLogging: 108 | # This is used to send plugin log statements directly to stout when running PMS from the command line. \ 109 | # Rarely used anymore 110 | 111 | plist_string = plistlib.writePlistToString(pl).replace('<', '<').replace('>', '>') 112 | 113 | with open(info_file, 'wb') as fp: 114 | fp.write(plist_string) 115 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LizardByte/PlexyGlass/35cbf6a3dab178f2ab11325e6fd5ff4a12bd48fa/tests/__init__.py -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # standard imports 4 | import os 5 | import sys 6 | 7 | # lib imports 8 | import pytest 9 | 10 | # add Contents directory to the system path 11 | pytest.root_dir = root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 12 | pytest.contents_dir = contents_dir = os.path.join(root_dir, 'Contents') 13 | if os.path.isdir(contents_dir): 14 | sys.path.append(contents_dir) 15 | else: 16 | raise Exception('Contents directory not found') 17 | -------------------------------------------------------------------------------- /tests/functional/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LizardByte/PlexyGlass/35cbf6a3dab178f2ab11325e6fd5ff4a12bd48fa/tests/functional/__init__.py -------------------------------------------------------------------------------- /tests/functional/test_docs.py: -------------------------------------------------------------------------------- 1 | import os 2 | import platform 3 | import pytest 4 | import shutil 5 | import subprocess 6 | 7 | 8 | def build_docs(): 9 | """Test building sphinx docs""" 10 | doc_types = [ 11 | 'html', 12 | 'epub', 13 | ] 14 | 15 | # remove existing build directory 16 | build_dir = os.path.join(os.getcwd(), 'docs', 'build') 17 | if os.path.isdir(build_dir): 18 | shutil.rmtree(path=build_dir) 19 | 20 | for doc_type in doc_types: 21 | print('Building {} docs'.format(doc_type)) 22 | result = subprocess.check_call( 23 | args=['make', doc_type], 24 | cwd=os.path.join(os.getcwd(), 'docs'), 25 | shell=True if platform.system() == 'Windows' else False, 26 | ) 27 | assert result == 0, 'Failed to build {} docs'.format(doc_type) 28 | 29 | # ensure docs built 30 | assert os.path.isfile(os.path.join(build_dir, 'html', 'index.html')), 'HTML docs not built' 31 | assert os.path.isfile(os.path.join(build_dir, 'epub', 'PlexyGlass.epub')), 'EPUB docs not built' 32 | 33 | 34 | def test_make_docs(): 35 | """Test building working sphinx docs""" 36 | build_docs() 37 | 38 | 39 | def test_make_docs_broken(): 40 | """Test building sphinx docs with known warnings""" 41 | # create a dummy rst file 42 | dummy_file = os.path.join(os.getcwd(), 'docs', 'source', 'dummy.rst') 43 | 44 | # write test to dummy file, creating the file if it doesn't exist 45 | with open(dummy_file, 'w+') as f: 46 | f.write('Dummy file\n') 47 | f.write('==========\n') 48 | 49 | # ensure CalledProcessError is raised 50 | with pytest.raises(subprocess.CalledProcessError): 51 | build_docs() 52 | 53 | # remove the dummy rst file 54 | os.remove(dummy_file) 55 | 56 | 57 | def test_rstcheck(): 58 | """Test rstcheck""" 59 | # get list of all the rst files in the project (skip venv and Contents/Libraries) 60 | rst_files = [] 61 | for root, dirs, files in os.walk(os.getcwd()): 62 | for f in files: 63 | if f.lower().endswith('.rst') and 'venv' not in root and 'Contents/Libraries' not in root: 64 | rst_files.append(os.path.join(root, f)) 65 | 66 | assert rst_files, 'No rst files found' 67 | 68 | # run rstcheck on all the rst files 69 | for rst_file in rst_files: 70 | print('Checking {}'.format(rst_file)) 71 | result = subprocess.check_call(['rstcheck', rst_file]) 72 | assert result == 0, 'rstcheck failed on {}'.format(rst_file) 73 | -------------------------------------------------------------------------------- /tests/unit/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LizardByte/PlexyGlass/35cbf6a3dab178f2ab11325e6fd5ff4a12bd48fa/tests/unit/__init__.py -------------------------------------------------------------------------------- /tests/unit/test_code.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # lib imports 4 | from plexhints.object_kit import MessageContainer 5 | 6 | # local imports 7 | from Code import Start 8 | from Code import ValidatePrefs 9 | from Code import default_prefs 10 | 11 | 12 | def test_validate_prefs(): 13 | result_container = ValidatePrefs() 14 | assert isinstance(result_container, MessageContainer) 15 | assert result_container.header == "Success" 16 | assert "Provided preference values are ok" in result_container.message 17 | 18 | # invalidate prefs, cannot do this due to: 19 | # TypeError: '_PreferenceSet' object does not support item assignment 20 | # Code.Prefs['int_plexapi_plexapi_timeout'] = 'not an integer' 21 | # result_container = ValidatePrefs() 22 | # assert isinstance(result_container, MessageContainer) 23 | # assert result_container.header == "Error" 24 | # assert "must be an integer" in result_container.message 25 | 26 | 27 | def test_validate_prefs_default_prefs(): 28 | # add a default pref and make sure it is not in DefaultPrefs.json 29 | default_prefs['new_pref'] = 'new_value' 30 | result_container = ValidatePrefs() 31 | assert isinstance(result_container, MessageContainer) 32 | assert result_container.header == "Error" 33 | assert "missing from 'DefaultPrefs.json'" in result_container.message 34 | 35 | 36 | def test_start(): 37 | # just run the function 38 | Start() 39 | 40 | 41 | def test_main(): 42 | # todo 43 | pass 44 | -------------------------------------------------------------------------------- /tests/unit/url_services/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LizardByte/PlexyGlass/35cbf6a3dab178f2ab11325e6fd5ff4a12bd48fa/tests/unit/url_services/__init__.py -------------------------------------------------------------------------------- /tests/unit/url_services/conftest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # standard imports 4 | import imp 5 | import os 6 | 7 | # lib imports 8 | import pytest 9 | 10 | # get Services directories 11 | services_dir = url_services_dir = os.path.join(pytest.contents_dir, 'Services') 12 | url_dir = os.path.join(services_dir, 'URL') 13 | 14 | service_file = 'ServiceCode.pys' 15 | 16 | 17 | @pytest.fixture(scope='module') 18 | def service_url_youtube(): 19 | # type: () -> object 20 | 21 | # we need to use imp.load_source() to import the service code because it is not a standard python module 22 | name = 'YouTube' 23 | _name = 'service_url_{}'.format(name.lower()) 24 | service = imp.load_source(_name, os.path.join(url_dir, name, service_file)) 25 | return service 26 | -------------------------------------------------------------------------------- /tests/unit/url_services/test_youtube.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # lib imports 4 | import pytest 5 | 6 | 7 | @pytest.fixture(scope='module') 8 | def service(service_url_youtube): 9 | yield service_url_youtube 10 | 11 | 12 | @pytest.fixture(scope='module', params=[ 13 | 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 14 | 'https://youtube.com/watch?v=dQw4w9WgXcQ', 15 | 'https://youtu.be/dQw4w9WgXcQ', 16 | ]) 17 | def url_list_1(request): 18 | yield request.param 19 | 20 | 21 | # only use this for normalize because the playlist takes a long time to process 22 | @pytest.fixture(scope='module', params=[ 23 | 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 24 | 'https://youtube.com/watch?v=dQw4w9WgXcQ', 25 | 'https://youtu.be/dQw4w9WgXcQ', 26 | 'https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ&start_radio=1' # mix 27 | ]) 28 | def url_list_2(request): 29 | yield request.param 30 | 31 | 32 | def test_extract_youtube_data(service, url_list_1): 33 | assert service.extract_youtube_data(url=url_list_1) 34 | 35 | 36 | def test_normalize_url(service, url_list_2): 37 | uut = service.NormalizeURL(url=url_list_2) 38 | assert uut 39 | assert uut == 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' 40 | 41 | 42 | def test_metadata_object_for_url(service, url_list_1): 43 | uut = service.MetadataObjectForURL(url=url_list_1) 44 | assert uut 45 | # todo - plexhints needs to be improved in order to test this properly 46 | 47 | 48 | def test_media_objects_for_url(service, url_list_1): 49 | uut = service.MediaObjectsForURL(url=url_list_1) 50 | assert uut 51 | assert isinstance(uut, list) 52 | assert len(uut) > 0 53 | 54 | for media in uut: 55 | assert media 56 | # todo - plexhints needs to be improved in order to test this properly 57 | --------------------------------------------------------------------------------