├── .gitignore
├── LICENSE.md
├── README.md
├── meta.json
├── providerMedia
└── a4kOfficial
│ ├── a4kOfficial.png
│ └── en
│ ├── adaptive
│ ├── curiositystream.png
│ ├── disneyplus.png
│ ├── hbomax.png
│ ├── hulu.png
│ ├── iplayer.png
│ ├── netflix.png
│ ├── paramountplus.png
│ ├── plex_composite.png
│ └── primevideo.png
│ └── direct
│ ├── library.png
│ └── plex_direct.png
├── providerModules
├── __init__.py
└── a4kOfficial
│ ├── __init__.py
│ ├── api
│ ├── __init__.py
│ ├── justwatch
│ │ ├── __init__.py
│ │ └── justwatchapi.py
│ └── plex.py
│ ├── common.py
│ ├── core
│ ├── __init__.py
│ ├── justwatch.py
│ ├── library.py
│ └── plex.py
│ ├── dom_parser.py
│ └── drm.py
└── providers
├── __init__.py
└── a4kOfficial
├── __init__.py
├── configure.py
└── en
├── __init__.py
├── adaptive
├── __init__.py
├── curiositystream.py
├── disneyplus.py
├── hbomax.py
├── hulu.py
├── iplayer.py
├── netflix.py
├── paramountplus.py
├── plex_composite.py
└── primevideo.py
└── direct
├── __init__.py
├── library.py
└── plex_direct.py
/.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 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 | db.sqlite3-journal
62 |
63 | # Flask stuff:
64 | instance/
65 | .webassets-cache
66 |
67 | # Scrapy stuff:
68 | .scrapy
69 |
70 | # Sphinx documentation
71 | docs/_build/
72 |
73 | # PyBuilder
74 | target/
75 |
76 | # Jupyter Notebook
77 | .ipynb_checkpoints
78 |
79 | # IPython
80 | profile_default/
81 | ipython_config.py
82 |
83 | # pyenv
84 | .python-version
85 |
86 | # pipenv
87 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
89 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
90 | # install all needed dependencies.
91 | #Pipfile.lock
92 |
93 | # celery beat schedule file
94 | celerybeat-schedule
95 |
96 | # SageMath parsed files
97 | *.sage.py
98 |
99 | # Environments
100 | .env
101 | .venv
102 | env/
103 | venv/
104 | ENV/
105 | env.bak/
106 | venv.bak/
107 |
108 | # Spyder project settings
109 | .spyderproject
110 | .spyproject
111 |
112 | # Rope project settings
113 | .ropeproject
114 |
115 | # mkdocs documentation
116 | /site
117 |
118 | # mypy
119 | .mypy_cache/
120 | .dmypy.json
121 | dmypy.json
122 |
123 | # Pyre type checker
124 | .pyre/
125 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "{}"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright {yyyy} {name of copyright owner}
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # a4kOfficial
2 | Provider package for Seren which interfaces with dedicated add-ons for many popular streaming services. This package leverages [JustWatchAPI](https://github.com/dawoudt/JustWatchAPI) to discover streaming services (from [JustWatch](https://www.justwatch.com/)) which offer the requested content, and defers playback to the respective add-on(s).
3 |
4 | # Supported Services
5 | | Service | Add-on | Plugin ID | Latest Tested Version |
6 | |:----------------|:------------------------------------|:----------------------------------|----------------------:|
7 | | BBC iPlayer | [iPlayer WWW](#iplayer-www) | `plugin.video.iplayerwww` | `Untested` |
8 | | CuriosityStream | [CuriosityStream](#curiositystream) | `slyguy.curiositystream` | `Untested` |
9 | | Disney+ | [Disney+](#disney) | `slyguy.disney.plus` | `0.12.1` |
10 | | HBO Max | [HBO Max](#hbo-max) | `slyguy.hbo.max` | `0.9.9` |
11 | | Hulu | [Hulu](#hulu) | `slyguy.hulu` | `0.2.1` |
12 | | Netflix | [Netflix](#netflix) | `plugin.video.netflix` | `1.18.8+matrix.1` |
13 | | Paramount+ | [Paramount+](#paramount) | `slyguy.paramount.plus` | `0.5.2` |
14 | | Plex | [Composite](#composite) | `plugin.video.composite_for_plex` | `0.9.5+matrix.1` |
15 | | Prime Video | [Prime Video](#prime-video) | `plugin.video.amazon-test` | `0.9.5+matrix.1` |
16 |
17 | Also included is a Kodi library scraper for local files, which needs no extra add-ons to be installed or any additional setup, and is enabled by default.
18 |
19 | # Requirements
20 | * Kodi Matrix 19.0 or greater
21 | * Seren 3.0.0 or greater
22 |
23 | # Installation
24 | This package can be installed from "Web Location" in Seren, using the url: https://github.com/a4k-openproject/a4kOfficial/zipball/master.
25 |
26 | Alternatively, open the URL above in any browser, save the resulting `.zip` file to some location, and "Browse" to it instead.
27 |
28 | # Configuration
29 | When installed for the first time, a prompt is shown asking which providers you would like to enable, with default selections based on which of the corresponding add-ons you also have installed. These selections can be toggled at this time, or at any subsequent time from Seren's Provider Manager.
30 |
31 | # Recommended Settings for Seren
32 | * Accounts
33 | - [x] `Enable Trakt Scrobbling`
34 | * Scraping
35 | - [x] `Enable Preemptive Termination`
36 | - [x] `Terminate if Adaptive Sources are Found`
37 | * Playback
38 | - [x] `Enable Smart Play`
39 | - [x] `Pre-emptive Scraping`
40 | - [x] `Enable Playing Next Dialog`
41 | * Sort & Filter
42 | - `Choose Items to Filter...`:
43 | - Video Codecs
44 | - [ ] `HEVC` (Recommended)
45 | - HDR Codecs
46 | - [ ] `DV` (Recommended)
47 | - [ ] `HDR` (Recommended)
48 | - [ ] `HYBRID` (Recommended)
49 | - Audio Codecs
50 | - [ ] `DD` (Recommended)
51 | - [ ] `DD+` (Recommended)
52 | - [ ] `ATMOS` (Recommended)
53 |
54 | - `Max Resolution`: `4K`
55 |
56 | # Supported Add-ons
57 | For most of the add-ons supported, there are a few settings which may require attention in order to maintain the best compatibility with these players. In general, the recommended settings for each add-on are meant to preserve the most functionality of both the playing add-on and Seren, ideally including the following where available:
58 |
59 | * Progress tracking with the service
60 | * Progress tracking with Trakt
61 | * Auto-play next episode
62 | * Skip intro and/or credits
63 | * Highest quality sources available
64 | * Fewest clicks to playback
65 |
66 | The general approach to the recommended settings below is to enable any "progress tracking" features (so that tracking works properly with the service), disable any "next episode" features (so that Seren's Playing Next feature will work properly), *optionally* enable any "skip intro and/or credits" features (at user's discretion). Any settings which are not mentioned are either recommended to be left at their default value, or the value won't affect these providers (as in the case of enabling/disabling menus, etc...).
67 |
68 | All of these add-ons require some kind of login process, which is usually initiated automatically whenever the add-on is opened for the first time, and will be the main requirement for any of them to playback sources (or, indeed, work at all).
69 |
70 | ## iPlayer WWW
71 | ### Installation
72 | Offical Repository Install:
73 | * Navigate to `Settings -> Add-ons -> Install from repository`
74 | * Choose `Kodi Repository`
75 | * Choose `Video Add-ons`
76 | * Choose `iPlayer WWW`
77 | * Choose `Install`
78 |
79 | ### Recommended Settings
80 | All defaults should be fine, though this one hasn't been tested yet.
81 |
82 | ## CuriosityStream
83 | ### Installation
84 | Enable Unknown Sources:
85 | * Navigate to `Settings -> System -> Add-ons`
86 | * Change the settings level to either `Advanced` or `Expert`
87 | * Enable `Unknown sources`
88 | * (Highly Recommended) Change `Update official add-ons from` to `Any repositories`
89 | * (Highly Recommended) Change `Updates` to `Notify, but don't install updates`
90 | * (Recommended) Enable `Show notifications`
91 |
92 | Add New Source:
93 | * Navigate to `Settings -> File Manager`
94 | * Choose `Add source`
95 | * Add the source: https://k.slyguy.xyz/
96 | * Name the source: `repository.slyguy`
97 |
98 | Install Repository:
99 | * Navigate to `Settings -> Add-ons -> Install from zip...`, and accept the prompt
100 | * Choose `repository.slyguy`
101 | * Choose `repository.slyguy.zip`, and accept the prompt
102 |
103 | SlyGuy Repository Install:
104 | * Navigate to `Settings -> Add-ons -> Install from repository`
105 | * Choose `SlyGuy Repository`
106 | * Choose `Video Add-ons`
107 | * Choose `CuriosityStream`
108 | * Choose `Install`
109 |
110 | ### Recommended Settings
111 | * Playback
112 | - `Playback Quality`: `Best`
113 |
114 | ## Disney+
115 | ### Installation
116 | * [Official Install Guide](https://www.matthuisman.nz/2020/04/disney-plus-kodi-add-on.html)
117 |
118 | ### Recommended Settings
119 | * Look & Feel
120 | - [ ] `Play Next Episode`
121 | - [ ] `Play Next Recommended Movie`
122 | - [x] `Skip Intros` (Optional)
123 | - [x] `Skip Credits` (Optional)
124 | - [x] `Disney+ Sync Playback`
125 | * Playback
126 | - `Playback Quality`: `Best`
127 |
128 |
129 | ## HBO Max
130 | ### Installation
131 | * [Official Install Guide](https://www.matthuisman.nz/2020/11/hbo-max-kodi-add-on.html)
132 |
133 | ### Recommended Settings
134 | * Look & Feel
135 | - [x] `Skip Intros` (Optional)
136 | - [x] `Skip Credits` (Optional)
137 | - [ ] `Play Next Episode`
138 | - [ ] `Play Next Recommended Movie`
139 | - [x] `HBO Max Sync Playback`
140 | * Playback
141 | - `Playback Quality`: `Best`
142 | - [x] `Dolby Digital (AC-3)`
143 | - [x] `Dolby Digital Plus (EC-3)`
144 | - [x] `Dolby Atmos`
145 | - [x] `H.265`
146 | - [x] `4K`
147 | - [x] `Dolby Vision`
148 |
149 | ## Hulu
150 | ### Installation
151 | * [Official Install Guide](https://www.matthuisman.nz/2021/10/hulu-kodi-add-on.html)
152 |
153 | ### Recommended Settings
154 | * General
155 | - [x] `Hulu Sync Playback`
156 | * Playback
157 | - `Playback Quality`: `Best`
158 | - [x] `EC3`
159 | - [x] `H265`
160 | - [x] `4K`
161 |
162 | ## Netflix
163 | ### Installation
164 | * [Official Install Guide](https://github.com/CastagnaIT/plugin.video.netflix)
165 |
166 | Besides the settings listed below, ensure that you've logged into the add-on using your Netflix credentials, and chosen a default profile. If a default profile isn't chosen ahead of time, a "Choose Profile" prompt will be shown before playback starts.
167 |
168 | ### Choosing Default Profile
169 | After successfully authenticating, the Profiles menu is shown. Highlight the profile you'd like to use for playback, open the context menu (`C`, right-click, or long-press), and choose `Set for auto-selection`. Repeat these steps once more, but choose `Set for library playback`. This ensures that the chosen profile will be used by default whenever one of our sources (or anything played by the Netflix add-on) is played. This menu can be reached again, if needed, by simply choosing `Profiles` from the root menu of the add-on.
170 |
171 | ### Recommended Settings
172 | * General
173 | - [x] `Synchronize the watched status of the videos with Netflix`
174 | * Playback
175 | - [x] `Remember audio / subtitle preferences`
176 | - [x] `Prefer stereo tracks by default`
177 | - [x] `Ask to skip intro and recap` (Optional)
178 |
179 | ## Paramount+
180 | * [Official Install Guide](https://www.matthuisman.nz/2021/06/paramount-plus-kodi-add-on.html)
181 |
182 | ### Installation
183 | ### Recommended Settings
184 | * Playback
185 | - `Playback Quality`: `Best`
186 | - [x] `Dolby Digital (AC-3)`
187 | - [x] `Dolby Digital Plus (EC-3)`
188 | - [x] `Dolby Atmos`
189 | - [x] `H.265`
190 | - [x] `4K`
191 | - [x] `Dolby Vision`
192 |
193 | ## Composite
194 | ### Installation
195 | Offical Repository Install:
196 | * Navigate to `Settings -> Add-ons -> Install from repository`
197 | * Choose `Kodi Repository`
198 | * Choose `Video Add-ons`
199 | * Choose `Composite`
200 | * Choose `Install`
201 |
202 | ### Recommended Settings
203 | * Playback
204 | - `Stream from PMS`: `Auto`
205 | - [x] `Intro skipping` (Optional)
206 | - [ ] `Always Transcode`
207 | - [ ] `Transcode > 8-bit`
208 | - [ ] `Transcode > 1080p`
209 | - [ ] `Transcode HEVC`
210 | * Advanced
211 | - [x] `Use full resolution thumbs`
212 | - [x] `Use full resolution fanart`
213 |
214 | ## Prime Video
215 | ### Installation
216 | * [Official Install Guide](https://github.com/Sandmann79/xbmc)
217 |
218 | ### Recommended Settings
219 | * General
220 | - `Playback with`: `Input Stream`
221 | - `Prefered Host`: `Auto`
222 | - `Intro/Recap scenes processing`: `Show Skip Button` (Optional)
223 |
--------------------------------------------------------------------------------
/meta.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "a4k-openproject",
3 | "version": "1.5.6",
4 | "name": "a4kOfficial",
5 | "update_directory": "https://www.github.com/a4k-openproject/a4kOfficial/archive/",
6 | "remote_meta": "https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/main/meta.json",
7 | "seren_version": "3.0.0",
8 | "setup_extension": "configure.py",
9 | "services": [],
10 | "settings": [
11 | {
12 | "id": "justwatch.country",
13 | "type": "str",
14 | "default": "US",
15 | "visible": true,
16 | "label": "JustWatch Country"
17 | },
18 | {
19 | "id": "general.firstrun",
20 | "type": "int",
21 | "default": 1,
22 | "visible": false,
23 | "label": "First Run"
24 | },
25 | {
26 | "id": "plex.token",
27 | "type": "str",
28 | "default": "",
29 | "visible": false,
30 | "label": "Plex Token"
31 | },
32 | {
33 | "id": "plex.client_id",
34 | "type": "str",
35 | "default": "",
36 | "visible": false,
37 | "label": "Plex Client ID"
38 | },
39 | {
40 | "id": "plex.device_id",
41 | "type": "str",
42 | "default": "",
43 | "visible": false,
44 | "label": "Plex Device ID"
45 | },
46 | {
47 | "id": "general.configure",
48 | "type": "bool",
49 | "default": false,
50 | "visible": true,
51 | "label": "Re-run Package Configuration",
52 | "hide_value": true,
53 | "action": {
54 | "module": "providers.a4kOfficial.configure",
55 | "function": "setup"
56 | }
57 | }
58 | ]
59 | }
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/a4kOfficial.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/a4kOfficial.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/curiositystream.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/curiositystream.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/disneyplus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/disneyplus.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/hbomax.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/hbomax.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/hulu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/hulu.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/iplayer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/iplayer.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/netflix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/netflix.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/paramountplus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/paramountplus.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/plex_composite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/plex_composite.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/adaptive/primevideo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/adaptive/primevideo.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/direct/library.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/direct/library.png
--------------------------------------------------------------------------------
/providerMedia/a4kOfficial/en/direct/plex_direct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerMedia/a4kOfficial/en/direct/plex_direct.png
--------------------------------------------------------------------------------
/providerModules/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerModules/__init__.py
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | PACKAGE_NAME = "a4kOfficial"
3 | ADDON_IDS = {
4 | "iplayer": {
5 | "plugin": "plugin.video.iplayerwww",
6 | "name": "BBC iPlayer",
7 | "type": "adaptive",
8 | },
9 | "curiositystream": {
10 | "plugin": "slyguy.curiositystream",
11 | "name": "CuriosityStream",
12 | "type": "adaptive",
13 | },
14 | "disneyplus": {
15 | "plugin": "slyguy.disney.plus",
16 | "name": "Disney+",
17 | "type": "adaptive",
18 | },
19 | "hbomax": {
20 | "plugin": "slyguy.hbo.max",
21 | "name": "HBO Max",
22 | "type": "adaptive",
23 | "settings": {
24 | "DD": "ac3_enabled",
25 | "DD+": "ec3_enabled",
26 | "ATMOS": "atmos_enabled",
27 | "HEVC": "h265",
28 | "4K": "4k_enabled",
29 | "DV": "dolby_vision",
30 | },
31 | },
32 | "hulu": {
33 | "plugin": "slyguy.hulu",
34 | "name": "Hulu",
35 | "type": "adaptive",
36 | "settings": {
37 | "DD+": "ec3",
38 | "HEVC": "h265",
39 | "4K": "4k",
40 | },
41 | },
42 | "library": {"plugin": None, "name": "Library", "type": "direct"},
43 | "netflix": {
44 | "plugin": "plugin.video.netflix",
45 | "name": "Netflix",
46 | "type": "adaptive",
47 | },
48 | "paramountplus": {
49 | "plugin": "slyguy.paramount.plus",
50 | "name": "Paramount+",
51 | "type": "adaptive",
52 | "settings": {
53 | "DD": "ac3_enabled",
54 | "DD+": "ec3_enabled",
55 | "ATMOS": "atmos_enabled",
56 | "HEVC": "h265",
57 | "4K": "4k_enabled",
58 | "DV": "dolby_vision",
59 | },
60 | },
61 | "plex_composite": {
62 | "plugin": "plugin.video.composite_for_plex",
63 | "name": "Plex (Composite)",
64 | "type": "adaptive",
65 | },
66 | "plex_direct": {"plugin": None, "name": "Plex (Direct)", "type": "direct"},
67 | "primevideo": {
68 | "plugin": "plugin.video.amazon-test",
69 | "name": "Prime Video",
70 | "type": "adaptive",
71 | },
72 | }
73 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/api/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providerModules/a4kOfficial/api/__init__.py
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/api/justwatch/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # MIT License
4 | #
5 | # Copyright (c) 2017 Dawoud Tabboush
6 | #
7 | # Permission is hereby granted, free of charge, to any person obtaining a copy
8 | # of this software and associated documentation files (the "Software"), to deal
9 | # in the Software without restriction, including without limitation the rights
10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | # copies of the Software, and to permit persons to whom the Software is
12 | # furnished to do so, subject to the following conditions:
13 | #
14 | # The above copyright notice and this permission notice shall be included in all
15 | # copies or substantial portions of the Software.
16 | #
17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | # SOFTWARE.
24 |
25 | from .justwatchapi import JustWatch
26 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/api/justwatch/justwatchapi.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # MIT License
4 | #
5 | # Copyright (c) 2017 Dawoud Tabboush
6 | #
7 | # Permission is hereby granted, free of charge, to any person obtaining a copy
8 | # of this software and associated documentation files (the "Software"), to deal
9 | # in the Software without restriction, including without limitation the rights
10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | # copies of the Software, and to permit persons to whom the Software is
12 | # furnished to do so, subject to the following conditions:
13 | #
14 | # The above copyright notice and this permission notice shall be included in all
15 | # copies or substantial portions of the Software.
16 | #
17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | # SOFTWARE.
24 |
25 | from datetime import datetime
26 | from datetime import timedelta
27 | import requests
28 | import sys
29 |
30 |
31 | HEADER = {"User-Agent": "JustWatch client (github.com/dawoudt/JustWatchAPI)"}
32 |
33 |
34 | class JustWatch:
35 | api_base_template = "https://apis.justwatch.com/content/{path}"
36 |
37 | def __init__(self, country="AU", use_sessions=True, **kwargs):
38 | self.kwargs = kwargs
39 | self.country = country
40 | self.kwargs_cinema = []
41 | self.requests = requests.Session() if use_sessions else requests
42 | self.locale = self.set_locale()
43 |
44 | def __del__(self):
45 | """Should really use context manager
46 | but this should do without changing functionality.
47 | """
48 | if isinstance(self.requests, requests.Session):
49 | self.requests.close()
50 |
51 | def set_locale(self):
52 | warn = "\nWARN: Unable to locale for {}! Defaulting to en_AU\n"
53 | default_locale = "en_AU"
54 | path = "locales/state"
55 | api_url = self.api_base_template.format(path=path)
56 |
57 | r = self.requests.get(api_url, headers=HEADER)
58 | try:
59 | r.raise_for_status()
60 | except requests.exceptions.HTTPError:
61 | sys.stderr.write(warn.format(self.country))
62 | return default_locale
63 | else:
64 | results = r.json()
65 |
66 | for result in results:
67 | if result["iso_3166_2"] == self.country or result["country"] == self.country:
68 |
69 | return result["full_locale"]
70 |
71 | sys.stderr.write(warn.format(self.country))
72 | return default_locale
73 |
74 | def search_for_item(self, query=None, **kwargs):
75 |
76 | path = "titles/{}/popular".format(self.locale)
77 | api_url = self.api_base_template.format(path=path)
78 |
79 | if kwargs:
80 | self.kwargs = kwargs
81 | if query:
82 | self.kwargs.update({"query": query})
83 | null = None
84 | payload = {
85 | "age_certifications": null,
86 | "content_types": null,
87 | "presentation_types": null,
88 | "providers": null,
89 | "genres": null,
90 | "languages": null,
91 | "release_year_from": null,
92 | "release_year_until": null,
93 | "monetization_types": null,
94 | "min_price": null,
95 | "max_price": null,
96 | "nationwide_cinema_releases_only": null,
97 | "scoring_filter_types": null,
98 | "cinema_release": null,
99 | "query": null,
100 | "page": null,
101 | "page_size": null,
102 | "timeline_type": null,
103 | "person_id": null,
104 | }
105 | for key, value in self.kwargs.items():
106 | if key in payload.keys():
107 | payload[key] = value
108 | else:
109 | print("{} is not a valid keyword".format(key))
110 | r = self.requests.post(api_url, json=payload, headers=HEADER)
111 |
112 | # Client should deal with rate-limiting. JustWatch may send a 429 Too Many Requests response.
113 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
114 |
115 | return r.json()
116 |
117 | def get_providers(self):
118 | path = "providers/locale/{}".format(self.locale)
119 | api_url = self.api_base_template.format(path=path)
120 | r = self.requests.get(api_url, headers=HEADER)
121 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
122 |
123 | return r.json()
124 |
125 | def get_genres(self):
126 | path = "genres/locale/{}".format(self.locale)
127 | api_url = self.api_base_template.format(path=path)
128 | r = self.requests.get(api_url, headers=HEADER)
129 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
130 |
131 | return r.json()
132 |
133 | def get_title(self, title_id, content_type="movie"):
134 | path = "titles/{content_type}/{title_id}/locale/{locale}".format(
135 | content_type=content_type, title_id=title_id, locale=self.locale
136 | )
137 |
138 | api_url = self.api_base_template.format(path=path)
139 | r = self.requests.get(api_url, headers=HEADER)
140 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
141 |
142 | return r.json()
143 |
144 | def search_title_id(self, query):
145 | """Returns a dictionary of titles returned
146 | from search and their respective ID's
147 |
148 | >>> ...
149 | >>> just_watch.get_title_id('The Matrix')
150 | {'The Matrix': 10, ... }
151 |
152 | """
153 |
154 | results = self.search_for_item(query)
155 | return {item["id"]: item["title"] for item in results["items"]}
156 |
157 | def get_season(self, season_id):
158 |
159 | header = HEADER
160 | api_url = "https://apis.justwatch.com/content/titles/show_season/{}/locale/{}".format(season_id, self.locale)
161 | r = self.requests.get(api_url, headers=header)
162 |
163 | # Client should deal with rate-limiting. JustWatch may send a 429 Too Many Requests response.
164 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
165 |
166 | return r.json()
167 |
168 | def get_episodes(self, show_id, page=""):
169 | """Fetches episodes details from the API, based on show_id.
170 | API returns 200 episodes (from newest to oldest) but takes a 'page' param.
171 | """
172 | header = HEADER
173 | api_url = "https://apis.justwatch.com/content/titles/show/{}/locale/{}/newest_episodes".format(
174 | show_id, self.locale
175 | )
176 | if page:
177 | api_url += "?page={}".format(page)
178 | r = self.requests.get(api_url, headers=header)
179 |
180 | # Client should deal with rate-limiting. JustWatch may send a 429 Too Many Requests response.
181 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
182 |
183 | return r.json()
184 |
185 | def get_cinema_times(self, title_id, content_type="movie", **kwargs):
186 |
187 | if kwargs:
188 | self.kwargs_cinema = kwargs
189 |
190 | null = None
191 | payload = {"date": null, "latitude": null, "longitude": null, "radius": 20000}
192 | for key, value in self.kwargs_cinema.items():
193 | if key in payload.keys():
194 | payload[key] = value
195 | else:
196 | print("{} is not a valid keyword".format(key))
197 |
198 | header = HEADER
199 | api_url = "https://apis.justwatch.com/content/titles/{}/{}/showtimes".format(content_type, title_id)
200 | r = self.requests.get(api_url, params=payload, headers=header)
201 |
202 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
203 |
204 | return r.json()
205 |
206 | def get_cinema_details(self, **kwargs):
207 |
208 | if kwargs:
209 | self.kwargs_cinema = kwargs
210 |
211 | null = None
212 | payload = {"latitude": null, "longitude": null, "radius": 20000}
213 | for key, value in self.kwargs_cinema.items():
214 | if key in payload.keys():
215 | payload[key] = value
216 | elif key == "date":
217 | # ignore the date value if passed
218 | pass
219 | else:
220 | print("{} is not a valid keyword".format(key))
221 |
222 | header = HEADER
223 | api_url = "https://apis.justwatch.com/content/cinemas/{}".format(self.locale)
224 | r = self.requests.get(api_url, params=payload, headers=header)
225 |
226 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
227 |
228 | return r.json()
229 |
230 | def get_upcoming_cinema(self, weeks_offset, nationwide_cinema_releases_only=True):
231 |
232 | header = HEADER
233 | payload = {
234 | "nationwide_cinema_releases_only": nationwide_cinema_releases_only,
235 | "body": {},
236 | }
237 | now_date = datetime.now()
238 | td = timedelta(weeks=weeks_offset)
239 | year_month_day = (now_date + td).isocalendar()
240 | api_url = "https://apis.justwatch.com/content/titles/movie/upcoming/{}/{}/locale/{}"
241 | api_url = api_url.format(year_month_day[0], year_month_day[1], self.locale)
242 |
243 | # this throws an error if you go too many weeks forward, so return a blank payload if we hit an error
244 | try:
245 | r = self.requests.get(api_url, params=payload, headers=header)
246 |
247 | # Client should deal with rate-limiting. JustWatch may send a 429 Too Many Requests response.
248 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
249 |
250 | return r.json()
251 | except:
252 | return {
253 | "page": 0,
254 | "page_size": 0,
255 | "total_pages": 1,
256 | "total_results": 0,
257 | "items": [],
258 | }
259 |
260 | def get_certifications(self, content_type="movie"):
261 |
262 | header = HEADER
263 | payload = {"country": self.country, "object_type": content_type}
264 | api_url = "https://apis.justwatch.com/content/age_certifications"
265 | r = self.requests.get(api_url, params=payload, headers=header)
266 |
267 | # Client should deal with rate-limiting. JustWatch may send a 429 Too Many Requests response.
268 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
269 |
270 | return r.json()
271 |
272 | def get_person_detail(self, person_id):
273 | path = "titles/person/{person_id}/locale/{locale}".format(person_id=person_id, locale=self.locale)
274 | api_url = self.api_base_template.format(path=path)
275 |
276 | r = self.requests.get(api_url, headers=HEADER)
277 | r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200
278 |
279 | return r.json()
280 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/api/plex.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from datetime import datetime
3 | from platform import machine, system
4 | import requests
5 | from requests.exceptions import RequestException
6 | import uuid
7 | from xml.etree import ElementTree
8 |
9 | import xbmc
10 | import xbmcgui
11 |
12 | from resources.lib.common import tools
13 | from resources.lib.modules.globals import g
14 |
15 | from providerModules.a4kOfficial import common
16 |
17 |
18 | class Plex:
19 | def __init__(self, client_id=None, token=None):
20 | self._base_url = "https://plex.tv"
21 | self._auth_url = self._base_url + "/link/"
22 | self._client_id = client_id or common.get_setting("plex.client_id")
23 | self._token = token or common.get_setting("plex.token")
24 | self._device_id = common.get_setting("plex.device_id")
25 |
26 | self.dialog = None
27 | self.progress = None
28 |
29 | self._headers = {
30 | "X-Plex-Device-Name": "a4kOfficial",
31 | "X-Plex-Product": "Seren",
32 | "X-Plex-Version": "1.3.0",
33 | "X-Plex-Platform": "Kodi",
34 | "X-Plex-Platform-Version": common.get_kodi_version(),
35 | "X-Plex-Device": system(),
36 | "X-Plex-Model": machine(),
37 | "X-Plex-Provides": "player",
38 | "X-Plex-Client-Identifier": self._client_id or str(hex(uuid.getnode())),
39 | "Accept": "application/json",
40 | }
41 | if self._token:
42 | self._headers["X-Plex-Token"] = self._token
43 |
44 | def _get(self, url, **kwargs):
45 | try:
46 | return requests.get(url, **kwargs)
47 | except RequestException as re:
48 | try:
49 | return requests.get(url, verify=True, **kwargs)
50 | except RequestException as re:
51 | common.log(f"a4kOfficial: Could not access Plex. {re}", "error")
52 |
53 | def auth(self):
54 | self.dialog = xbmcgui.Dialog()
55 | self.progress = xbmcgui.DialogProgress()
56 | self._start_auth_time = datetime.utcnow().timestamp()
57 |
58 | self._token = None
59 | url = self._base_url + "/pins"
60 | data = requests.post(url, headers=self._headers)
61 |
62 | if data.status_code != 201:
63 | common.log("Failed to authorize Plex: {} response from {}".format(data.status_code, url))
64 |
65 | try:
66 | pin = data.json().get("pin", {})
67 | code = pin.get("code", "")
68 | self._device_id = pin.get("id", "")
69 | self._expire_auth_time = datetime.strptime(pin.get("expires_at", ""), "%Y-%m-%dT%H:%M:%SZ").timestamp()
70 | except Exception as e:
71 | common.log("a4kOfficial: Failed to authorize Plex: {}".format(e), "error")
72 | return
73 |
74 | tools.copy2clip(code)
75 | self._check_url = self._base_url + "/pins/{}".format(self._device_id)
76 |
77 | self.progress.create("a4kOfficial: Plex Authorization")
78 |
79 | while self._token is None:
80 | current_auth_time = datetime.utcnow().timestamp()
81 | if self.progress.iscanceled() or current_auth_time > self._expire_auth_time:
82 | self.progress.close()
83 | break
84 | self.auth_loop(code, current_auth_time)
85 |
86 | return self._token is not None
87 |
88 | def auth_loop(self, code, current_auth_time):
89 | self.progress.update(
90 | int(
91 | (
92 | float(current_auth_time - self._start_auth_time)
93 | / float(self._expire_auth_time - self._start_auth_time)
94 | )
95 | * 100
96 | ),
97 | g.get_language_string(30018).format(g.color_string(self._auth_url))
98 | + "\n"
99 | + g.get_language_string(30019).format(g.color_string(code))
100 | + "\n"
101 | + g.get_language_string(30047),
102 | )
103 |
104 | xbmc.sleep(5000)
105 | data = requests.get(self._check_url, headers=self._headers)
106 |
107 | if data.status_code != 200:
108 | common.log("Failed to authorize Plex: {} response from {}".format(data.status_code, self._check_url))
109 | return
110 |
111 | try:
112 | pin = data.json().get("pin", {})
113 | self._token = pin.get("auth_token", "")
114 | self._client_id = pin.get("client_identifier", "")
115 | except Exception:
116 | self._token = None
117 | self._client_id = None
118 |
119 | if self._token:
120 | self.progress.close()
121 | self._headers.update(
122 | {
123 | "X-Plex-Client-Identifier": self._client_id,
124 | "X-Plex-Token": self._token,
125 | }
126 | )
127 |
128 | common.set_setting("plex.token", self._token)
129 | common.set_setting("plex.client_id", self._client_id)
130 |
131 | device_id = self.get_device_id()
132 | if device_id is not None:
133 | common.set_setting("plex.device_id", device_id)
134 |
135 | self.dialog.ok("a4kOfficial", "Successfully authenticated with Plex.")
136 |
137 | def get_device_id(self):
138 | url = self._base_url + "/devices.xml"
139 | results = requests.get(url, headers=self._headers)
140 |
141 | if results.status_code != 200:
142 | common.log("Failed to authorize Plex: {} response from {}".format(results.status_code, url))
143 | return
144 |
145 | try:
146 | container = ElementTree.fromstring(results.text)
147 | devices = container.findall("Device")
148 | for device in devices:
149 | device_token = device.get("token", "")
150 | if device_token == self._token:
151 | return device.get("id")
152 | except Exception as e:
153 | common.log("a4kOfficial: Failed to authorize Plex: {}".format(e), "error")
154 | return
155 |
156 | def get_resources(self):
157 | url = self._base_url + "/api/v2/resources"
158 | results = self._get(url, params={"includeHttps": 1}, headers=self._headers)
159 |
160 | if results is not None and results.status_code != 200:
161 | common.log(f"Failed to list Plex resources: {results.status_code} response from {url}")
162 | return
163 |
164 | listings = []
165 | try:
166 | data = results.json()
167 | for resource in data:
168 | if "server" in resource.get("provides", ""):
169 | access_token = resource.get("accessToken", "")
170 | if not access_token:
171 | continue
172 |
173 | connections = resource.get("connections", [])
174 | for connection in connections:
175 | url = connection.get("uri", "")
176 | local = connection.get("local", True)
177 |
178 | if ".plex.direct" in url and not local:
179 | listings.append((url, access_token))
180 | except Exception as e:
181 | common.log(f"a4kOfficial: Failed to list Plex resources: {e}")
182 | return
183 |
184 | return listings
185 |
186 | def search(self, resource, query, **kwargs):
187 | kwargs.pop("type", "movie")
188 | url = resource[0] + "/search"
189 | params = {"query": query}
190 | params.update(**kwargs)
191 | self._headers["X-Plex-Token"] = resource[1]
192 |
193 | results = self._get(url, params=params, headers=self._headers)
194 | self._headers["X-Plex-Token"] = self._token
195 | if results and results.ok:
196 | return results.json().get("MediaContainer", {}).get("Metadata", [])
197 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/common.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import math
3 | import os
4 | import requests
5 | from requests.exceptions import RequestException
6 |
7 | import xbmc
8 | import xbmcaddon
9 |
10 | from resources.lib.common import provider_tools
11 | from resources.lib.modules.globals import g
12 | from resources.lib.modules.providers.install_manager import ProviderInstallManager
13 |
14 | from providerModules.a4kOfficial import PACKAGE_NAME
15 |
16 |
17 | def log(msg, level="info"):
18 | g.log(f"{msg}", level)
19 |
20 |
21 | def get_setting(id):
22 | return provider_tools.get_setting(PACKAGE_NAME, id)
23 |
24 |
25 | def set_setting(id, value):
26 | return provider_tools.set_setting(PACKAGE_NAME, id, value)
27 |
28 |
29 | def change_provider_status(scraper=None, status="enabled"):
30 | ProviderInstallManager().flip_provider_status("a4kOfficial", scraper, status)
31 |
32 |
33 | def check_for_addon(plugin):
34 | if plugin is None:
35 | return False
36 | status = get_infoboolean(f"System.AddonIsEnabled({plugin})")
37 | return status
38 |
39 |
40 | def check_url(url):
41 | try:
42 | return requests.get(url).ok
43 | except RequestException as re:
44 | log(f"a4kOfficial: Could not access {url}. {re}", "error")
45 | return False
46 |
47 |
48 | def get_all_relative_py_files(file):
49 | files = os.listdir(os.path.dirname(file))
50 | return [filename[:-3] for filename in files if not filename.startswith("__") and filename.endswith(".py")]
51 |
52 |
53 | def parseDOM(html, name="", attrs=None, ret=False):
54 | if attrs:
55 | import re
56 |
57 | attrs = dict((key, re.compile(value + ("$" if value else ""))) for key, value in attrs.items())
58 | from providerModules.a4kOfficial import dom_parser
59 |
60 | results = dom_parser.parse_dom(html, name, attrs, ret)
61 |
62 | if ret:
63 | results = [result.attrs[ret.lower()] for result in results]
64 | else:
65 | results = [result.content for result in results]
66 |
67 | return results
68 |
69 |
70 | def execute_jsonrpc(method, params):
71 | import json
72 |
73 | call_params = {"id": 1, "jsonrpc": "2.0", "method": method, "params": params}
74 | call = json.dumps(call_params)
75 | response = xbmc.executeJSONRPC(call)
76 | return json.loads(response)
77 |
78 |
79 | def convert_size(size_bytes):
80 | size_bytes = int(size_bytes)
81 | if size_bytes == 0:
82 | return "0B"
83 | size_name = ("B", "KB", "MB", "GB")
84 | i = int(math.floor(math.log(size_bytes, 1024)))
85 | p = math.pow(1024, i)
86 | s = round(size_bytes / p, 2)
87 | return f"{s}{size_name[i]}"
88 |
89 |
90 | def get_kodi_version(short=False):
91 | version = xbmc.getInfoLabel("System.BuildVersion")
92 | if short:
93 | version = int(version[:2])
94 | return version
95 |
96 |
97 | def get_system_platform():
98 | platform = "unknown"
99 | for p in ["android", "linux", "uwp", "windows", "osx", "ios", "tvos"]:
100 | if xbmc.getCondVisibility(f"system.platform.{p}"):
101 | platform = p
102 |
103 | return platform
104 |
105 |
106 | def get_package_providers():
107 | manager = ProviderInstallManager()
108 | providers = manager.known_providers
109 |
110 | return [p for p in providers if p["package"] == PACKAGE_NAME]
111 |
112 |
113 | def get_infoboolean(label):
114 | return xbmc.getCondVisibility(label)
115 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/core/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import time
3 |
4 | import xbmcgui
5 |
6 | from resources.lib.modules.exceptions import PreemptiveCancellation
7 |
8 | from providerModules.a4kOfficial import common
9 |
10 |
11 | class Core:
12 | def __init__(self):
13 | self.start_time = time.time()
14 | self.sources = []
15 | self._scraper = self.__module__.split(".")[-1]
16 |
17 | def _return_results(self, source_type, sources, preemptive=False, extra=None):
18 | if preemptive:
19 | common.log(
20 | f"a4kOfficial.{source_type}.{self._scraper}: cancellation requested",
21 | "info",
22 | )
23 | if extra:
24 | common.log(f"a4kOfficial.{source_type}.{self._scraper}: {extra}", "info")
25 | common.log(
26 | f"a4kOfficial.{source_type}.{self._scraper}: {len(sources)}",
27 | "info",
28 | )
29 | common.log(
30 | f"a4kOfficial.{source_type}.{self._scraper}: took {int((time.time() - self.start_time) * 1000)} ms",
31 | "info",
32 | )
33 | common.log(
34 | f"a4kOfficial.{source_type}.{self._scraper}: {sources}",
35 | "debug",
36 | )
37 |
38 | return sources
39 |
40 | def _make_source(self, item, ids, simple_info, info, **kwargs):
41 | source = {
42 | "scraper": self._scraper,
43 | }
44 | source.update(ids)
45 |
46 | return source
47 |
48 | def _make_episode_source(self, item, ids, simple_info, info, **kwargs):
49 | return self._make_source(item, ids, simple_info, info, base_url=self._episode_url, type="episode", **kwargs)
50 |
51 | def _make_movie_source(self, item, ids, simple_info, info, **kwargs):
52 | return self._make_source(item, ids, simple_info, info, base_url=self._movie_url, type="movie", **kwargs)
53 |
54 | def _process_movie_item(self, item, simple_info, info, **kwargs):
55 | source = self._process_item(item, simple_info, info, type="movie", **kwargs)
56 | return source
57 |
58 | def _process_show_item(self, item, simple_info, info, **kwargs):
59 | source = self._process_item(
60 | item,
61 | simple_info,
62 | info,
63 | type="episode",
64 | **kwargs,
65 | )
66 | return source
67 |
68 | def episode(self, simple_info, info, **kwargs):
69 | if self._api is None:
70 | return self._return_results("episode", [])
71 |
72 | try:
73 | items = self._make_show_query(simple_info=simple_info)
74 |
75 | for item in items:
76 | source = self._process_show_item(item, simple_info, info, **kwargs)
77 | if source is not None:
78 | self.sources.append(source)
79 | if kwargs.get("single"):
80 | break
81 | except PreemptiveCancellation:
82 | return self._return_results("episode", self.sources, preemptive=True)
83 | except Exception as e:
84 | return self._return_results("episode", self.sources, extra=e)
85 | else:
86 | return self._return_results("episode", self.sources)
87 |
88 | def movie(self, title, year, imdb, simple_info, info, **kwargs):
89 | if self._api is None:
90 | return self._return_results("movie", [])
91 |
92 | try:
93 | items = self._make_movie_query(title=simple_info["title"], year=int(simple_info["year"]))
94 |
95 | for item in items:
96 | source = self._process_movie_item(item, simple_info, info, **kwargs)
97 | if source is not None:
98 | self.sources.append(source)
99 | if kwargs.get("single"):
100 | break
101 | except PreemptiveCancellation:
102 | return self._return_results("movie", self.sources, preemptive=True)
103 | except Exception as e:
104 | return self._return_results("episode", self.sources, extra=e)
105 | else:
106 | return self._return_results("movie", self.sources)
107 |
108 | @staticmethod
109 | def get_listitem(return_data):
110 | list_item = xbmcgui.ListItem(path=return_data["url"], offscreen=True)
111 | list_item.setContentLookup(False)
112 | list_item.setProperty("isFolder", "false")
113 | list_item.setProperty("isPlayable", "true")
114 |
115 | return list_item
116 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/core/justwatch.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import xbmcaddon
3 |
4 | from resources.lib.common.source_utils import clean_title
5 | from resources.lib.modules.exceptions import PreemptiveCancellation
6 |
7 | from providerModules.a4kOfficial import ADDON_IDS, common, drm
8 | from providerModules.a4kOfficial.core import Core
9 | from providerModules.a4kOfficial.api.justwatch import JustWatch
10 |
11 |
12 | class JustWatchCore(Core):
13 | def __init__(self, providers, scheme="standard_web"):
14 | super().__init__()
15 | self._country = common.get_setting("justwatch.country")
16 |
17 | try:
18 | self._api = JustWatch(country=self._country)
19 | except PreemptiveCancellation:
20 | self._api = None
21 |
22 | self._monetization_types = ["free", "flatrate"]
23 | self._plugin = ADDON_IDS[self._scraper]["plugin"]
24 | self._service_offers = []
25 |
26 | self._providers = providers
27 | self._scheme = scheme
28 | self._base_url = f"plugin://{self._plugin}"
29 | self._movie_url = self._base_url + "{movie_url}"
30 | self._episode_url = self._base_url + "{episode_url}"
31 |
32 | @staticmethod
33 | def _make_release_title(item, simple_info, info, type):
34 | if type == "movie":
35 | return simple_info['title']
36 | elif type == "episode":
37 | return (
38 | f"{simple_info['show_title']}: "
39 | f"S{int(simple_info['season_number']):02}E{int(simple_info['episode_number']):02} - "
40 | f"{simple_info['episode_title']}"
41 | )
42 | else:
43 | return item['title']
44 |
45 | def _make_source(self, item, ids, simple_info, info, **kwargs):
46 | source = super()._make_source(item, ids, simple_info, info, **kwargs)
47 | source.update(
48 | {
49 | "release_title": JustWatchCore._make_release_title(item, simple_info, info, kwargs["type"]),
50 | "quality": self._get_offered_resolutions(item),
51 | "info": self._get_info_from_settings(),
52 | "plugin": self._plugin,
53 | "debrid_provider": self._plugin,
54 | "provider_name_override": ADDON_IDS[self._scraper]["name"],
55 | }
56 | )
57 |
58 | base_url = kwargs["base_url"]
59 | source["url"] = base_url.format(**ids)
60 |
61 | return source
62 |
63 | def _get_info_from_settings(self):
64 | addon = xbmcaddon.Addon(self._plugin)
65 | info = set()
66 | settings = ADDON_IDS[self._scraper].get("settings", {})
67 |
68 | for setting in settings:
69 | if addon.getSettingBool(settings[setting]):
70 | info.add(setting)
71 |
72 | if drm.get_widevine_level() == "L3" or ("4K" in settings and not addon.getSettingBool(settings["4K"])):
73 | info.difference_update({"HDR", "DV", "HYBRID"})
74 |
75 | return info
76 |
77 | def __make_query(self, query, type, **kwargs):
78 | items = self._api.search_for_item(
79 | query=clean_title(query),
80 | content_types=[type],
81 | providers=self._providers,
82 | monetization_types=self._monetization_types,
83 | **kwargs,
84 | ).get("items", [])
85 |
86 | return items
87 |
88 | def _make_movie_query(self, **kwargs):
89 | items = self.__make_query(
90 | query=kwargs["title"],
91 | type="movie",
92 | release_year_from=int(kwargs["year"]) - 1,
93 | release_year_until=int(kwargs["year"]) + 1,
94 | )
95 |
96 | return items
97 |
98 | def _make_show_query(self, **kwargs):
99 | items = self.__make_query(query=kwargs["simple_info"]["show_title"], type="show")
100 |
101 | return items
102 |
103 | def _process_item(self, item, simple_info, info, type, **kwargs):
104 | source = None
105 | if not self._get_service_offers(item):
106 | return None
107 |
108 | jw_title = self._api.get_title(title_id=item["id"], content_type="show" if type == "episode" else type)
109 | external_ids = jw_title.get("external_ids", {})
110 | tmdb_ids = [i["external_id"] for i in external_ids if i["provider"] == "tmdb"]
111 |
112 | tmdb_id = info["info"].get("tmdb_show_id" if type == "episode" else "tmdb_id")
113 | season = int(simple_info.get("season_number", 0))
114 | episode = int(simple_info.get("episode_number", 0))
115 | if len(tmdb_ids) >= 1 and int(tmdb_ids[0]) == tmdb_id:
116 | service_id = self._get_service_id(item, season, episode)
117 | if not service_id:
118 | return None
119 |
120 | if type == "movie":
121 | source = self._make_movie_source(item, {"movie_id": service_id}, simple_info, info, **kwargs)
122 | elif type == "episode":
123 | episodes = self._api.get_episodes(item["id"])["items"]
124 | episode_item = [
125 | i for i in episodes if i["season_number"] == int(season) and i["episode_number"] == int(episode)
126 | ]
127 |
128 | if not episode_item:
129 | return None
130 | episode_item = episode_item[0]
131 | ids = {"show_id": service_id}
132 | ids.update(self._get_service_ep_id(service_id, episode_item, season, episode))
133 |
134 | if not ids.get("episode_id"):
135 | return None
136 |
137 | source = self._make_episode_source(episode_item, ids, simple_info, info, **kwargs)
138 |
139 | return source
140 |
141 | @staticmethod
142 | def _get_quality(offer):
143 | types = {
144 | "4K": ("4K",),
145 | "HD": (
146 | "1080p",
147 | "720p",
148 | ),
149 | "SD": ("SD",),
150 | }
151 |
152 | return types[offer["presentation_type"].upper()]
153 |
154 | def _get_service_offers(self, item, offers=None):
155 | offers = offers or item.get("offers", [])
156 | service_offers = [
157 | o
158 | for o in offers
159 | if o.get("package_short_name") in self._providers and o.get("monetization_type") in self._monetization_types
160 | ]
161 | self._service_offers.extend(service_offers)
162 |
163 | return service_offers
164 |
165 | def _get_offered_resolutions(self, item):
166 | if not self._service_offers:
167 | return None
168 |
169 | resolutions = set()
170 | for offer in self._service_offers:
171 | resolutions.update(self._get_quality(offer))
172 |
173 | settings = ADDON_IDS[self._scraper].get("settings", {})
174 |
175 | try:
176 | if drm.get_widevine_level() == "L3" or (
177 | "4K" in settings and not xbmcaddon.Addon(self._plugin).getSettingBool(settings["4K"])
178 | ):
179 | resolutions.discard("4K")
180 | except Exception:
181 | common.log(f"Could not identify WV capabilities from {self._plugin}", "error")
182 |
183 | order = {key: i for i, key in enumerate(["4K", "1080p", "720p", "SD"])}
184 |
185 | return "/".join(sorted(list(resolutions), key=lambda x: order[x]))
186 |
187 | def _get_service_id(self, item, season=0, episode=0):
188 | if not self._service_offers:
189 | return None
190 |
191 | offer = self._service_offers[0]
192 | url = offer.get("urls", {}).get(self._scheme, "")
193 | if not common.check_url(url):
194 | return None
195 |
196 | id = url.rstrip("/").split("/")[-1]
197 |
198 | return id
199 |
200 | def _get_service_ep_id(self, show_id, item, season, episode):
201 | return {"episode_id": self._get_service_id(item)}
202 |
203 | def episode(self, simple_info, info, **kwargs):
204 | return super().episode(simple_info, info, single=True, **kwargs)
205 |
206 | def movie(self, title, year, imdb, simple_info, info, **kwargs):
207 | return super().movie(title, year, imdb, simple_info, info, single=True, **kwargs)
208 |
209 | @staticmethod
210 | def get_listitem(return_data):
211 | scraper = return_data["scraper"]
212 | plugin = ADDON_IDS[scraper]["plugin"]
213 | if not common.check_for_addon(plugin):
214 | common.log(
215 | f"a4kOfficial: '{plugin}' is not installed; disabling '{scraper}'",
216 | "info",
217 | )
218 | common.change_provider_status(scraper, "disabled")
219 | else:
220 | return super(JustWatchCore, JustWatchCore).get_listitem(return_data)
221 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/core/library.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from resources.lib.common.source_utils import de_string_size
3 |
4 | from providerModules.a4kOfficial import common
5 | from providerModules.a4kOfficial.core import Core
6 |
7 |
8 | class LibraryCore(Core):
9 | def __init__(self):
10 | super().__init__()
11 |
12 | @staticmethod
13 | def get_quality(width):
14 | if width == 0:
15 | return "Unknown"
16 | elif width >= 2160:
17 | return "4K"
18 | elif width >= 1920:
19 | return "1080p"
20 | elif width >= 1280:
21 | return "720p"
22 | elif width < 1280:
23 | return "SD"
24 |
25 | @staticmethod
26 | def get_file_info(db_details):
27 | file_info = {}
28 | filename = db_details.get("file", "")
29 | if not filename:
30 | return {}
31 |
32 | size = (
33 | common.execute_jsonrpc(
34 | method="Files.GetFileDetails",
35 | params={"file": filename, "media": "video", "properties": ["size"]},
36 | )
37 | .get("result", {})
38 | .get("filedetails", {})
39 | .get("size", 0)
40 | )
41 | file_info["size"] = de_string_size(common.convert_size(size))
42 |
43 | stream_details = db_details.get("streamdetails", {})
44 | audio_details = stream_details.get("audio", [])
45 | audio_details = audio_details[0] if len(audio_details) > 0 else {}
46 | video_details = stream_details.get("video", [])
47 | video_details = video_details[0] if len(video_details) > 0 else {}
48 |
49 | file_info["info"] = set()
50 | if audio_channels := audio_details.get("channels"):
51 | file_info["info"].add(f"{audio_channels}ch")
52 | if audio_codec := audio_details.get("codec"):
53 | file_info["info"].add("dts" if audio_codec == "dca" else audio_codec)
54 | if video_codec := video_details.get("codec"):
55 | file_info["info"].add("h264" if video_codec == "avc1" else video_codec)
56 | if video_codec := video_details.get("stereomode"):
57 | file_info["info"].add("3D")
58 |
59 | file_info["quality"] = LibraryCore.get_quality(video_details.get("width", 0))
60 |
61 | return file_info
62 |
63 | def _make_source(self, item, ids, source_info, db_details, **kwargs):
64 | source = super()._make_source(item, ids, source_info, db_details, **kwargs)
65 | source.update(
66 | {
67 | "release_title": db_details["label"],
68 | "info": source_info["info"],
69 | "size": source_info["size"],
70 | "quality": source_info["quality"],
71 | "url": db_details.get("file", ""),
72 | }
73 | )
74 |
75 | return source
76 |
77 | def __make_query(self, method, params, **kwargs):
78 | result = common.execute_jsonrpc(method=method, params=params, **kwargs).get("result", {})
79 |
80 | return result
81 |
82 | def _make_show_query(self, **kwargs):
83 | result = self.__make_query(
84 | method="VideoLibrary.GetTVShows",
85 | params={
86 | "properties": ["uniqueid", "title"],
87 | },
88 | )
89 |
90 | return result.get("tvshows", {})
91 |
92 | def _make_movie_query(self, **kwargs):
93 | result = self.__make_query(
94 | method="VideoLibrary.GetMovies",
95 | params={
96 | "properties": ["uniqueid", "title", "originaltitle", "file"],
97 | "filter": {
98 | "and": [
99 | {"field": "title", "operator": "startswith", "value": kwargs['title']},
100 | {
101 | "or": [
102 | {
103 | "field": "year",
104 | "operator": "is",
105 | "value": str(kwargs['year'] - 1),
106 | },
107 | {"field": "year", "operator": "is", "value": str(kwargs['year'])},
108 | {
109 | "field": "year",
110 | "operator": "is",
111 | "value": str(kwargs['year'] + 1),
112 | },
113 | ]
114 | },
115 | ]
116 | },
117 | },
118 | )
119 |
120 | return result.get("movies", {})
121 |
122 | def _process_item(self, db_item, simple_info, info, type, **kwargs):
123 | source = None
124 | db_details = None
125 | external_ids = None
126 | ids = None
127 |
128 | if type == "movie":
129 | db_details = self.__make_query(
130 | method="VideoLibrary.GetMovieDetails",
131 | params={
132 | "properties": ["streamdetails", "file", "uniqueid"],
133 | "movieid": db_item.get("movieid", ""),
134 | },
135 | ).get("moviedetails", {})
136 | if not db_details:
137 | return None
138 |
139 | external_ids = db_details.get("uniqueid", {})
140 | ids = {
141 | "tmdb": info["info"].get("tmdb_id"),
142 | "imdb": info["info"].get("imdb_id"),
143 | "trakt": info["info"].get("trakt_id"),
144 | }
145 | elif type == "episode":
146 | db_details = self.__make_query(
147 | method="VideoLibrary.GetEpisodes",
148 | params={
149 | "properties": ["streamdetails", "file", "uniqueid"],
150 | "tvshowid": db_item.get("tvshowid", ""),
151 | "filter": {
152 | "and": [
153 | {
154 | "field": "season",
155 | "operator": "is",
156 | "value": str(info["info"]["season"]),
157 | },
158 | {
159 | "field": "episode",
160 | "operator": "is",
161 | "value": str(info["info"]["episode"]),
162 | },
163 | ]
164 | },
165 | },
166 | )
167 |
168 | db_details = db_details.get("episodes", [])
169 | if not db_details:
170 | return None
171 |
172 | db_details = db_details[0]
173 | external_ids = db_item.get("uniqueid", {})
174 | ids = {
175 | "tmdb": info["info"].get("tmdb_show_id"),
176 | "tvdb": info["info"].get("tvdb_show_id"),
177 | "trakt": info["info"].get("trakt_show_id"),
178 | }
179 |
180 | if all(
181 | [int(external_ids.get(i, -1)) if not i == "imdb" else external_ids.get(i, -1) in [-1, ids[i]] for i in ids]
182 | ):
183 | source_info = self.get_file_info(db_details)
184 | source = self._make_source(None, ids, source_info, db_details)
185 |
186 | return source
187 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/core/plex.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import pickle
3 | import os
4 | import re
5 |
6 | import xbmcaddon
7 | import xbmcvfs
8 |
9 | from resources.lib.common.source_utils import (
10 | clean_title,
11 | get_info,
12 | get_quality,
13 | de_string_size,
14 | )
15 | from resources.lib.modules.exceptions import PreemptiveCancellation
16 |
17 | from providerModules.a4kOfficial import ADDON_IDS, common
18 | from providerModules.a4kOfficial.api.plex import Plex
19 | from providerModules.a4kOfficial.core import Core
20 |
21 |
22 | PLEX_AUDIO = {"dca": "dts", "dca-ma": "hdma"}
23 |
24 |
25 | class PlexCore(Core):
26 | def __init__(self):
27 | super().__init__()
28 | self._plugin = ADDON_IDS[self._scraper]["plugin"]
29 | self._client_id, self._token = self._get_auth()
30 |
31 | try:
32 | self._api = Plex(self._client_id, self._token)
33 | self._resources = self._api.get_resources()
34 | except PreemptiveCancellation:
35 | self._api = None
36 | self._resources = None
37 |
38 | self._base_url = None
39 | self._movie_url = None
40 | self._episode_url = None
41 |
42 | def _get_auth(self):
43 | if common.check_for_addon(self._plugin):
44 | addon = xbmcaddon.Addon(self._plugin)
45 | client_id = addon.getSetting("client_id")
46 |
47 | addon_path = xbmcvfs.translatePath(addon.getAddonInfo("profile"))
48 | cache_path = os.path.join(addon_path, "cache", "servers", "plexhome_user.pcache")
49 | with open(cache_path, "rb") as f:
50 | cache = pickle.load(f)
51 |
52 | token = cache.get("myplex_user_cache").split("|")[1]
53 | else:
54 | client_id = common.get_setting("plex.client_id")
55 | token = common.get_setting("plex.token")
56 |
57 | return client_id, token
58 |
59 | def _make_source(self, item, url, simple_info, info, **kwargs):
60 | source = super()._make_source(item, url, simple_info, info, **kwargs)
61 |
62 | source.update(
63 | {
64 | "release_title": item["filename"],
65 | "info": get_info(item["filename"]).union(get_info(item["info"])),
66 | "size": de_string_size(item["size"]),
67 | "quality": get_quality(f"{item['filename']} ({item['quality']})"),
68 | "url": kwargs["base_url"].format(**url),
69 | "debrid_provider": f"{item['source_title']} - {item['library_title']}",
70 | "provider_name_override": ADDON_IDS[self._scraper]["name"],
71 | "plugin": self._plugin,
72 | }
73 | )
74 |
75 | return source
76 |
77 | def __make_query(self, resource, query, **kwargs):
78 | result = self._api.search(resource, query, **kwargs) or []
79 |
80 | return result
81 |
82 | def _make_show_query(self, **kwargs):
83 | result = []
84 | for resource in self._resources:
85 | result.extend(
86 | [
87 | dict(resource=resource, **i)
88 | for i in self.__make_query(resource, kwargs["simple_info"]["episode_title"], type="episode")
89 | ]
90 | )
91 |
92 | return result
93 |
94 | def _make_movie_query(self, **kwargs):
95 | result = []
96 | for resource in self._resources:
97 | result.extend(
98 | [
99 | dict(resource=resource, **i)
100 | for i in self.__make_query(
101 | resource,
102 | kwargs["title"],
103 | year=kwargs["year"],
104 | type="movie",
105 | )
106 | ]
107 | )
108 |
109 | return result
110 |
111 | def _process_item(self, item, simple_info, info, type, **kwargs):
112 | try:
113 | item_type = item.get("type", "")
114 | resource = item.get("resource", ())
115 | media = item.get("Media", [{}])[0]
116 | meta_title = item.get("title", "")
117 | source_title = item.get("sourceTitle", "")
118 | library_title = item.get("librarySectionTitle", "")
119 | year = int(item.get("year", 0))
120 |
121 | quality = media.get("videoResolution", "Unknown")
122 | part = media.get("Part", [{}])[0]
123 | info = " ".join(
124 | [
125 | media.get("container", ""),
126 | media.get("videoCodec", ""),
127 | media.get("videoProfile", ""),
128 | PLEX_AUDIO.get(media.get("audioCodec"), media.get("audioCodec", "")),
129 | media.get("audioProfile", ""),
130 | str(media.get("audioChannels", "2")) + "ch",
131 | ]
132 | )
133 |
134 | size = common.convert_size(part.get("size", 0))
135 | file = part.get("file", "")
136 | key = part.get("key", "") if not self._plugin else item.get("key", "")
137 | except Exception as e:
138 | common.log(f"a4kOfficial: Failed to process Plex source: {e}", "error")
139 | return
140 |
141 | filename = file
142 | if "/" in file:
143 | filename = file.rsplit("/", 1)[-1]
144 | elif "\\" in file:
145 | filename = file.rsplit("\\", 1)[-1]
146 |
147 | if source_year := re.search(r"((?:1|2)(?:9|0)(?:[0-9]{2}))", filename):
148 | year = int(source_year.group(0))
149 |
150 | if item_type != type:
151 | return
152 |
153 | source = {
154 | "filename": filename,
155 | "info": info,
156 | "size": size,
157 | "quality": quality,
158 | "source_title": source_title,
159 | "library_title": library_title,
160 | }
161 | url = {"base_url": resource[0], "token": resource[1]}
162 |
163 | if type == "movie":
164 | titles = [simple_info["title"], *simple_info.get("aliases", [])]
165 |
166 | if year < int(simple_info["year"]) - 1 or year > int(simple_info["year"]) + 1:
167 | return
168 | elif not any([clean_title(meta_title) == clean_title(title) for title in titles]):
169 | return
170 |
171 | url.update({"movie_id": key})
172 | return self._make_movie_source(
173 | source,
174 | url,
175 | simple_info,
176 | info,
177 | **kwargs,
178 | )
179 | elif type == "episode":
180 | show_title = item.get("grandparentTitle", "")
181 | episode_title = item.get("title", "")
182 | season = int(item.get("parentIndex", 0))
183 | episode = int(item.get("index", 0))
184 | titles = [simple_info["show_title"], *simple_info.get("show_aliases", [])]
185 |
186 | if not (season == int(simple_info["season_number"]) and episode == int(simple_info["episode_number"])):
187 | return
188 | elif not (
189 | any([clean_title(show_title) == clean_title(title) for title in titles])
190 | and clean_title(simple_info["episode_title"]) == clean_title(episode_title)
191 | ):
192 | return
193 |
194 | url.update({"episode_id": key})
195 | return self._make_episode_source(source, url, simple_info, info, **kwargs)
196 |
197 | @staticmethod
198 | def get_listitem(return_data):
199 | scraper = return_data["scraper"]
200 | if not common.check_for_addon(ADDON_IDS[scraper]["plugin"]):
201 | common.log(
202 | f"a4kOfficial: '{ADDON_IDS[scraper]['plugin']}' is not installed; disabling '{scraper}'",
203 | "info",
204 | )
205 | common.change_provider_status(scraper, "disabled")
206 | else:
207 | return super(PlexCore, PlexCore).get_listitem(return_data)
208 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/dom_parser.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Based on Parsedom for XBMC plugins
4 | Copyright (C) 2010-2011 Tobias Ussing And Henrik Mosgaard Jensen
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | """
19 |
20 | import re
21 | from collections import namedtuple
22 |
23 | DomMatch = namedtuple('DOMMatch', ['attrs', 'content'])
24 | re_type = type(re.compile(''))
25 |
26 |
27 | def __get_dom_content(html, name, match):
28 | if match.endswith('/>'):
29 | return ''
30 |
31 | # override tag name with tag from match if possible
32 | tag = re.match('<([^\s/>]+)', match)
33 | if tag:
34 | name = tag.group(1)
35 |
36 | start_str = '<%s' % name
37 | end_str = "%s" % name
38 |
39 | # start/end tags without matching case cause issues
40 | start = html.find(match)
41 | end = html.find(end_str, start)
42 | pos = html.find(start_str, start + 1)
43 |
44 | while pos < end and pos != -1: # Ignore too early return
45 | tend = html.find(end_str, end + len(end_str))
46 | if tend != -1:
47 | end = tend
48 | pos = html.find(start_str, pos + 1)
49 |
50 | if start == -1 and end == -1:
51 | result = ''
52 | elif start > -1 and end > -1:
53 | result = html[start + len(match) : end]
54 | elif end > -1:
55 | result = html[:end]
56 | elif start > -1:
57 | result = html[start + len(match) :]
58 | else:
59 | result = ''
60 |
61 | return result
62 |
63 |
64 | def __get_dom_elements(item, name, attrs):
65 | if not attrs:
66 | pattern = '(<%s(?:\s[^>]*>|/?>))' % name
67 | this_list = re.findall(pattern, item, re.M | re.S | re.I)
68 | else:
69 | last_list = None
70 | for key, value in attrs.items():
71 | value_is_regex = isinstance(value, re_type)
72 | value_is_str = isinstance(value, str)
73 | pattern = '''(<{tag}[^>]*\s{key}=(?P['"])(.*?)(?P=delim)[^>]*>)'''.format(tag=name, key=key)
74 | re_list = re.findall(pattern, item, re.M | re.S | re.I)
75 | if value_is_regex:
76 | this_list = [r[0] for r in re_list if re.match(value, r[2])]
77 | else:
78 | temp_value = [value] if value_is_str else value
79 | this_list = [r[0] for r in re_list if set(temp_value) <= set(r[2].split(' '))]
80 |
81 | if not this_list:
82 | has_space = (value_is_regex and ' ' in value.pattern) or (value_is_str and ' ' in value)
83 | if not has_space:
84 | pattern = '''(<{tag}[^>]*\s{key}=((?:[^\s>]|/>)*)[^>]*>)'''.format(tag=name, key=key)
85 | re_list = re.findall(pattern, item, re.M | re.S | re.I)
86 | if value_is_regex:
87 | this_list = [r[0] for r in re_list if re.match(value, r[1])]
88 | else:
89 | this_list = [r[0] for r in re_list if value == r[1]]
90 |
91 | if last_list is None:
92 | last_list = this_list
93 | else:
94 | last_list = [item for item in this_list if item in last_list]
95 | this_list = last_list
96 |
97 | return this_list
98 |
99 |
100 | def __get_attribs(element):
101 | attribs = {}
102 | for match in re.finditer(
103 | '''\s+(?P[^=]+)=\s*(?:(?P["'])(?P.*?)(?P=delim)|(?P[^"'][^>\s]*))''', element
104 | ):
105 | match = match.groupdict()
106 | value1 = match.get('value1')
107 | value2 = match.get('value2')
108 | value = value1 if value1 is not None else value2
109 | if value is None:
110 | continue
111 | attribs[match['key'].lower().strip()] = value
112 | return attribs
113 |
114 |
115 | def parse_dom(html, name='', attrs=None, req=False, exclude_comments=False):
116 | if attrs is None:
117 | attrs = {}
118 | name = name.strip()
119 | if isinstance(html, str) or isinstance(html, DomMatch):
120 | html = [html]
121 | elif isinstance(html, bytes): # and six.PY2:
122 | try:
123 | html = [html.decode("utf-8")] # Replace with chardet thingy
124 | except:
125 | try:
126 | html = [html.decode("utf-8", "replace")]
127 | except:
128 | html = [html]
129 | elif not isinstance(html, list):
130 | return ''
131 |
132 | if not name:
133 | return ''
134 |
135 | if not isinstance(attrs, dict):
136 | return ''
137 |
138 | if req:
139 | if not isinstance(req, list):
140 | req = [req]
141 | req = set([key.lower() for key in req])
142 |
143 | all_results = []
144 | for item in html:
145 | if isinstance(item, DomMatch):
146 | item = item.content
147 |
148 | if exclude_comments:
149 | item = re.sub(re.compile('', re.DOTALL), '', item)
150 |
151 | results = []
152 | for element in __get_dom_elements(item, name, attrs):
153 | attribs = __get_attribs(element)
154 | if req and not req <= set(attribs.keys()):
155 | continue
156 | temp = __get_dom_content(item, name, element).strip()
157 | results.append(DomMatch(attribs, temp))
158 | item = item[item.find(temp, item.find(element)) :]
159 | all_results += results
160 |
161 | return all_results
162 |
--------------------------------------------------------------------------------
/providerModules/a4kOfficial/drm.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import xbmcdrm
3 |
4 | from providerModules.a4kOfficial import common
5 |
6 | WV_UUID = "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
7 |
8 | WV_L1 = "L1"
9 | WV_L2 = "L2"
10 | WV_L3 = "L3"
11 |
12 | FAKE_L1 = [
13 | "7011",
14 | ]
15 |
16 |
17 | def get_widevine_level():
18 | wv_level = None
19 |
20 | if common.get_kodi_version(short=True) > 17:
21 | try:
22 | crypto = xbmcdrm.CryptoSession(WV_UUID, "AES/CBC/NoPadding", "HmacSHA256")
23 |
24 | if not wv_level:
25 | wv_level = crypto.GetPropertyString("securityLevel")
26 | if wv_level:
27 | wv_level = wv_level.upper()
28 |
29 | try:
30 | if wv_level == WV_L1:
31 | system_id = crypto.GetPropertyString("systemId")
32 | if system_id in FAKE_L1:
33 | wv_level = WV_L3
34 | except:
35 | pass
36 |
37 | except Exception as e:
38 | common.log(f"a4kOfficial: Failed detecting Widevine security level. {e}")
39 |
40 | if not wv_level:
41 | wv_level = WV_L3
42 |
43 | return wv_level or WV_L3
44 |
--------------------------------------------------------------------------------
/providers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providers/__init__.py
--------------------------------------------------------------------------------
/providers/a4kOfficial/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a4k-openproject/a4kOfficial/7fe0a637a937cd1e928cf1efa9a95169f52b96d4/providers/a4kOfficial/__init__.py
--------------------------------------------------------------------------------
/providers/a4kOfficial/configure.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import importlib
3 | import requests
4 |
5 | import xbmcgui
6 |
7 | from resources.lib.modules.globals import g
8 |
9 | from providerModules.a4kOfficial import common, ADDON_IDS
10 |
11 |
12 | _ipify = "https://api.ipify.org?format=json"
13 | _ipinfo = "https://ipinfo.io/{}/json"
14 |
15 |
16 | def setup(*args, **kwargs):
17 | common.set_setting("justwatch.country", _get_country_code() or "US")
18 |
19 | dialog = xbmcgui.Dialog()
20 | providers = {p['provider_name']: p for p in common.get_package_providers()}
21 | automatic = [_get_provider_status(scraper, kwargs.get("first_run"), providers) for scraper in ADDON_IDS]
22 |
23 | choices = (
24 | dialog.multiselect(
25 | "a4kOfficial: Choose providers to enable",
26 | [ADDON_IDS[i[0]]["name"] for i in automatic],
27 | preselect=[i for i in range(len(automatic)) if automatic[i][1]],
28 | )
29 | or []
30 | )
31 |
32 | for i in range(len(automatic)):
33 | scraper, status = automatic[i][:2]
34 | if i in choices:
35 | module = f"providers.a4kOfficial.en.{ADDON_IDS[scraper]['type']}.{scraper}"
36 | provider = importlib.import_module(module)
37 |
38 | if hasattr(provider, "setup"):
39 | if dialog.yesno(
40 | "a4kOfficial",
41 | f"Do you want to enable and setup {g.color_string(ADDON_IDS[scraper]['name'])}?",
42 | ):
43 | success = provider.setup()
44 | if not success:
45 | common.log(f"a4kOfficial.{scraper}: Setup not complete; disabling")
46 | common.change_provider_status(scraper, f"{'en' if success else 'dis'}abled")
47 | else:
48 | common.change_provider_status(scraper, "enabled")
49 | else:
50 | common.change_provider_status(scraper, "disabled")
51 |
52 | common.set_setting("general.firstrun", 0)
53 |
54 |
55 | def _get_current_ip():
56 | data = requests.get(_ipify)
57 | if data.ok:
58 | return data.json().get("ip", "0.0.0.0")
59 |
60 |
61 | def _get_country_code():
62 | ip = _get_current_ip()
63 | data = requests.get(_ipinfo.format(ip))
64 |
65 | if data.ok:
66 | return data.json().get("country", "US")
67 |
68 |
69 | def _get_provider_status(scraper=None, initial=False, providers=[]):
70 | if initial:
71 | status = common.check_for_addon(ADDON_IDS[scraper]["plugin"])
72 | else:
73 | status = True if providers[scraper]["status"] == "enabled" else False
74 | return (scraper, status)
75 |
76 |
77 | if common.get_setting("general.firstrun"):
78 | setup(first_run=True)
79 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from . import adaptive
3 | from . import direct
4 |
5 |
6 | def get_torrent():
7 | return []
8 |
9 |
10 | def get_hosters():
11 | return []
12 |
13 |
14 | def get_adaptive():
15 | return adaptive.__all__
16 |
17 |
18 | def get_direct():
19 | return direct.__all__
20 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial import common
3 |
4 | __all__ = common.get_all_relative_py_files(__file__)
5 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/curiositystream.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
3 |
4 |
5 | class sources(JustWatchCore):
6 | def __init__(self):
7 | super().__init__(providers=["cts"])
8 |
9 | self._movie_url = f"{self._movie_url.format(movie_url='/?_=play&_play=1&id={movie_id}')}"
10 | self._episode_url = f"{self._episode_url.format(episode_url='/?_=play&_play=1&id={episode_id}')}"
11 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/disneyplus.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
3 |
4 |
5 | class sources(JustWatchCore):
6 | def __init__(self):
7 | super().__init__(providers=["dnp"], scheme="deeplink_web")
8 |
9 | self._movie_url = f"{self._movie_url.format(movie_url='/?_=play&_play=1&content_id={movie_id}')}"
10 | self._episode_url = f"{self._episode_url.format(episode_url='/?_=play&_play=1&content_id={episode_id}')}"
11 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/hbomax.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
3 |
4 |
5 | class sources(JustWatchCore):
6 | def __init__(self):
7 | super().__init__(providers=["hmf", "hba", "hbm"])
8 |
9 | self._movie_url = f"{self._movie_url.format(movie_url='/?_=play&slug={movie_id}')}"
10 | self._episode_url = f"{self._episode_url.format(episode_url='/?_=play&slug={episode_id}')}"
11 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/hulu.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
3 |
4 |
5 | class sources(JustWatchCore):
6 | def __init__(self):
7 | super().__init__(providers=["hlu"])
8 |
9 | self._movie_url = f"{self._movie_url.format(movie_url='/?_=play&id={movie_id}')}"
10 | self._episode_url = f"{self._episode_url.format(episode_url='/?_=play&id={episode_id}')}"
11 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/iplayer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import json
3 | import re
4 | import requests
5 | from urllib.parse import quote_plus
6 |
7 | from providerModules.a4kOfficial import common
8 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
9 |
10 |
11 | class sources(JustWatchCore):
12 | def __init__(self):
13 | super().__init__(providers=["bbc"])
14 |
15 | self._movie_url = (
16 | f"{self._movie_url.format(movie_url='/?mode=202&name=null&url={movie_id}&iconimage=null&description=null')}"
17 | )
18 | self._episode_url = f"{self._episode_url.format(episode_url='/?mode=202&name=null&url={episode_id}&iconimage=null&description=null')}"
19 |
20 | def _make_source(self, item, ids, simple_info, info, **kwargs):
21 | source = self._make_source(item, ids, simple_info, info, **kwargs)
22 |
23 | base_url = kwargs["base_url"]
24 | source["url"] = base_url.format(**({k: quote_plus(v) for k, v in ids.items()}))
25 |
26 | def _get_service_id(self, item, season=0, episode=0):
27 | if not self._service_offers:
28 | return None
29 |
30 | offer = self._service_offers[0]
31 | url = offer["urls"][self._scheme]
32 | if not common.check_url(url):
33 | return None
34 |
35 | return self._get_service_ep_id(url, item, season, episode) if "/episodes/" in url else url
36 |
37 | def _get_service_ep_id(self, show_id, item, season, episode):
38 | seriesId = None
39 | series_split = show_id.split("seriesId=")
40 | if type(series_split == list) and len(series_split) > 1:
41 | seriesId = show_id.split("seriesId=")[1]
42 |
43 | r = requests.get(show_id, timeout=10).text
44 | eps = re.findall("__IPLAYER_REDUX_STATE__\s*=\s*({.+?});", r)
45 | if eps:
46 | eps = json.loads(eps[0])
47 |
48 | if seriesId:
49 | seasons = eps.get("header", {}).get("availableSlices", {})
50 | series_id = [s.get("id", "") for s in seasons if int(re.sub("[^0-9]", "", s["title"])) == season]
51 | if series_id:
52 | series_id = series_id[0]
53 |
54 | if not series_id == seriesId:
55 | show_id = show_id.replace(seriesId, series_id)
56 | r = requests.get(show_id, timeout=10).text
57 | eps = re.findall("__IPLAYER_REDUX_STATE__\s*=\s*({.+?});", r)
58 | if eps:
59 | eps = json.loads(eps[0])
60 |
61 | eps = eps.get("entities", {})
62 | eps = [e.get("props", {}).get("href", "") for e in eps]
63 | ep = [e for e in eps if re.compile(rf"series-{season}-{episode}-").findall(e)]
64 | if ep:
65 | ep = ep[0]
66 | ep = "https://www.bbc.co.uk" + ep if not ep.startswith("http") else ep
67 |
68 | return None if not common.check_url(ep) else {"episode_id": ep}
69 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/netflix.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import re
3 | import requests
4 |
5 | from providerModules.a4kOfficial import common
6 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
7 |
8 |
9 | INSTANT_WATCHER_COUNTRIES = {
10 | "AR": "21",
11 | "AU": "23",
12 | "BE": "26",
13 | "BR": "29",
14 | "CA": "33",
15 | "CO": "36",
16 | "CZ": "307",
17 | "FR": "45",
18 | "DE": "39",
19 | "GR": "327",
20 | "HK": "331",
21 | "HU": "334",
22 | "IS": "265",
23 | "IN": "337",
24 | "IL": "336",
25 | "IT": "269",
26 | "JP": "267",
27 | "LT": "357",
28 | "MY": "378",
29 | "MX": "65",
30 | "NL": "67",
31 | "PL": "392",
32 | "PT": "268",
33 | "RU": "402",
34 | "SG": "408",
35 | "SK": "412",
36 | "ZA": "447",
37 | "KR": "348",
38 | "ES": "270",
39 | "SE": "73",
40 | "CH": "34",
41 | "TH": "425",
42 | "TR": "432",
43 | "GB": "46",
44 | "US": "78",
45 | }
46 |
47 |
48 | class sources(JustWatchCore):
49 | def __init__(self):
50 | super().__init__(providers=["nfx", "nfk"])
51 |
52 | self._movie_url = f"{self._movie_url.format(movie_url='/play/movie/{movie_id}/')}"
53 | self._episode_url = (
54 | f"{self._episode_url.format(episode_url='/play/show/{show_id}/season/{season_id}/episode/{episode_id}')}"
55 | )
56 |
57 | def _get_service_ep_id(self, show_id, item, season, episode):
58 | code = INSTANT_WATCHER_COUNTRIES.get(self._country, "78")
59 | url = f"https://www.instantwatcher.com/netflix/{code}/title/{show_id}"
60 | r = requests.get(url, timeout=10).text
61 |
62 | r = common.parseDOM(r, "div", attrs={"class": "tdChildren-titles"})[0]
63 | seasons = re.findall(
64 | r'()',
65 | r,
66 | flags=re.I | re.S,
67 | )
68 | _season = [s for s in seasons if int(re.findall(r">Season (.+?)", s, flags=re.I | re.S)[0]) == season][0]
69 | episodes = common.parseDOM(_season, "a", ret="data-title-id")
70 | episode_id = episodes[int(episode)]
71 |
72 | return (
73 | None
74 | if not common.check_url(f"https://www.netflix.com/watch/{episode_id}")
75 | else {"season_id": episodes[0], "episode_id": episode_id}
76 | )
77 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/paramountplus.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import re
3 |
4 | from providerModules.a4kOfficial import common
5 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
6 |
7 |
8 | class sources(JustWatchCore):
9 | def __init__(self):
10 | super().__init__(providers=["pmp"])
11 |
12 | self._movie_url = f"{self._movie_url.format(movie_url='/?_=play&video_id={movie_id}')}"
13 | self._episode_url = f"{self._episode_url.format(episode_url='/?_=play&video_id={episode_id}')}"
14 |
15 | def _get_service_id(self, item, season=0, episode=0):
16 | if not self._service_offers:
17 | return None
18 |
19 | offer = self._service_offers[0]
20 | url = offer["urls"][self._scheme]
21 | if not common.check_url(url):
22 | return None
23 |
24 | id = url.split("?")[0].split("/")[-1] if item["object_type"] == "movie" else re.findall("/video/(.+?)/", url)[0]
25 |
26 | return id
27 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/plex_composite.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from urllib.parse import quote
3 |
4 | from providerModules.a4kOfficial.core.plex import PlexCore
5 |
6 |
7 | class sources(PlexCore):
8 | def __init__(self):
9 | super().__init__()
10 |
11 | self._base_url = f"plugin://{self._plugin}"
12 | self._movie_url = f"{self._base_url}" + "/?mode=5&url={base_url}{movie_id}"
13 | self._episode_url = f"{self._base_url}" + "/?mode=5&url={base_url}{episode_id}"
14 |
15 | def episode(self, simple_info, info, **kwargs):
16 | return super().episode(simple_info, info, single=False, **kwargs)
17 |
18 | def movie(self, title, year, imdb, simple_info, info, **kwargs):
19 | return super().movie(title, year, imdb, simple_info, info, single=False, **kwargs)
20 |
21 | def _make_source(self, item, url, simple_info, info, **kwargs):
22 | source = super()._make_source(item, url, simple_info, info, **kwargs)
23 |
24 | source.update({"url": kwargs["base_url"].format(**{k: quote(v) for k, v in url.items()})})
25 |
26 | return source
27 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/adaptive/primevideo.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial import common
3 | from providerModules.a4kOfficial.core.justwatch import JustWatchCore
4 |
5 |
6 | class sources(JustWatchCore):
7 | def __init__(self):
8 | super().__init__(providers=["amp", "amz", "prv"])
9 |
10 | self._movie_url = f"{self._movie_url.format(movie_url='/?mode=PlayVideo&name=None&adult=0&trailer=0&selbitrate=0&asin={movie_id}')}"
11 | self._episode_url = f"{self._episode_url.format(episode_url='/?mode=PlayVideo&name=None&adult=0&trailer=0&selbitrate=0&asin={episode_id}')}"
12 |
13 | def _get_service_id(self, item, season=0, episode=0):
14 | if not self._service_offers:
15 | return None
16 |
17 | offer = self._service_offers[0]
18 | url = offer["urls"][self._scheme]
19 | if not common.check_url(url):
20 | return None
21 |
22 | id = url.rstrip("/").split("gti=")[1]
23 |
24 | return id
25 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/direct/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial import common
3 |
4 | __all__ = common.get_all_relative_py_files(__file__)
5 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/direct/library.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial.core.library import LibraryCore
3 |
4 |
5 | class sources(LibraryCore):
6 | def __init__(self):
7 | super().__init__()
8 |
--------------------------------------------------------------------------------
/providers/a4kOfficial/en/direct/plex_direct.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from providerModules.a4kOfficial import common
3 | from providerModules.a4kOfficial.api.plex import Plex
4 | from providerModules.a4kOfficial.core.plex import PlexCore
5 |
6 | _api = Plex()
7 |
8 |
9 | def setup():
10 | success = _api.auth()
11 | for setting in ["plex.token", "plex.client_id", "plex.device_id"]:
12 | common.log(common.get_setting(setting))
13 |
14 | return success
15 |
16 |
17 | class sources(PlexCore):
18 | def __init__(self):
19 | super().__init__()
20 |
21 | self._movie_url = "{base_url}{movie_id}" + f"&X-Plex-Token={self._token}"
22 | self._episode_url = "{base_url}{episode_id}" + f"&X-Plex-Token={self._token}"
23 |
24 | def episode(self, simple_info, info, **kwargs):
25 | return super().episode(simple_info, info, single=False, **kwargs)
26 |
27 | def movie(self, title, year, imdb, simple_info, info, **kwargs):
28 | return super().movie(title, year, imdb, simple_info, info, single=False, **kwargs)
29 |
--------------------------------------------------------------------------------