Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge up 0.6.x to master #209

Merged
merged 209 commits into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
ff2ba05
Add class for memoize decorator
glensc Mar 6, 2021
676671f
Add CacheDisabledDecorator to disable requests cache via decorator
glensc Mar 6, 2021
3316feb
Add decorators module
glensc Mar 19, 2021
8795dfd
Add PlexApi class abstraction
glensc Mar 6, 2021
b5c8517
Add library_sections method
glensc Mar 6, 2021
13f924f
Implement excluded-libraries support to library_sections
glensc Mar 6, 2021
41d8ece
Add memoize and nocache decorators to plex api methods
glensc Mar 19, 2021
0f88d47
Use new PlexApi methods
glensc Mar 19, 2021
b1ce5cd
Initialize plex_server via constructor parameter
glensc Mar 19, 2021
d8664f7
Create CONTRIBUTING.md file
glensc Mar 31, 2021
dde09ac
Update CONTRIBUTING.md
glensc Mar 31, 2021
f820388
Update CONTRIBUTING.md
glensc Mar 31, 2021
7889c58
Fix typo
glensc Mar 31, 2021
a77c030
Remove codestsyle block that we do not apply
glensc Mar 31, 2021
19e8ab2
Update new issue link
glensc Mar 31, 2021
70a8165
Remove bug report guide
glensc Mar 31, 2021
49c4ba3
Update references
glensc Mar 31, 2021
1fa3063
Avoid passive voice
glensc Mar 31, 2021
4394ac2
Merge pull request #159 from Taxel/glensc-patch-1
glensc Apr 4, 2021
da99895
Merge pull request #142 from glensc/plex-api
glensc Apr 4, 2021
4fb18ea
Add click 7.1.2 dependency
glensc Mar 6, 2021
bcd5bbd
Use click to launch application
glensc Mar 6, 2021
53e25b7
Merge pull request #122 from Taxel/add-click
glensc Apr 4, 2021
28f3fc0
Update logging configuration to add stdout logger
glensc Mar 6, 2021
cb2c041
Remove extra print statements
glensc Mar 20, 2021
fef14ea
Update finished sync messages loglevel to debug
glensc Mar 6, 2021
450bc7d
Merge pull request #149 from Taxel/logging
glensc Apr 4, 2021
024221e
Add dockerfile to build the app
glensc Mar 22, 2021
8d27bcf
Setup .dockerignore to fine tune docker context
glensc Mar 22, 2021
17193e4
Merge pull request #151 from Taxel/docker-image
glensc Apr 4, 2021
49136bc
Add clear_trakt_collections as subcommand
glensc Mar 20, 2021
a584879
Invoke sync subcommand by default
glensc Mar 20, 2021
f9aad77
Remove standalone clear_trakt_collections.py entrypoint
glensc Mar 20, 2021
5f85bec
Merge pull request #163 from glensc/add-clear_collections-command
glensc Apr 4, 2021
54ae4b5
Add measure_time helper to log block timing
glensc Mar 6, 2021
01532cb
Add requests_cache module wrapper
glensc Mar 6, 2021
305cc29
Use requests_cache wrapper
glensc Mar 6, 2021
d2becc7
Merge pull request #141 from glensc/requests-cache
glensc Apr 4, 2021
3e6fbe9
Merge pull request #164 from glensc/measure_time
glensc Apr 4, 2021
64153ab
Use memoize from functools
glensc Mar 20, 2021
86d3923
Use lru_cache directly for py<3.8
glensc Mar 20, 2021
6e3baf1
Drop our own memoize, no longer needed
glensc Apr 4, 2021
410911c
Merge pull request #165 from glensc/functools-memoize
glensc Apr 4, 2021
da84b91
Update to use config save() method
glensc Apr 4, 2021
8a29929
Merge pull request #167 from glensc/plex-connect-env
glensc Apr 5, 2021
6ef09d5
Add TraktApi class dealing with caching/fetching trakt api methods
glensc Mar 6, 2021
d43ba36
Add liked_lists method
glensc Mar 6, 2021
d00b420
Add movie_collection method
glensc Mar 6, 2021
d6f96b0
Add watched_shows method
glensc Mar 6, 2021
941483b
Add watchlist_movies method
glensc Mar 6, 2021
4b466be
Add movie_ratings method
glensc Mar 6, 2021
203f118
Add ratings helper
glensc Mar 6, 2021
78af891
Add is_movie/is_show helpers
glensc Mar 6, 2021
5595891
Add a click command to sync
glensc Mar 6, 2021
fd42983
Use sync from click command
glensc Apr 4, 2021
c0aad21
Drop old main sync code
glensc Apr 4, 2021
e24bcf5
Ensure plex server is accessed with cache disabled
glensc Apr 4, 2021
f5da78d
Merge pull request #166 from glensc/sync-cli
glensc Apr 5, 2021
bed968c
Identify as PlexTraktSync for X-Plex-Platform header
glensc Apr 4, 2021
c027404
Merge pull request #168 from glensc/plex-device
glensc Apr 5, 2021
2b5c76a
Add movies and shows accessors
glensc Mar 19, 2021
a72d295
Use plex.movie_sections/plex.show_sections
glensc Mar 19, 2021
e2a73f0
Remove unused is_movie/is_show
glensc Mar 20, 2021
e7f31d6
Merge pull request #173 from glensc/movies-helper
glensc Apr 5, 2021
06a4b03
Add PlexLibrarySection class
glensc Mar 19, 2021
d2bac0b
Use PlexLibrarySection for movie_sections
glensc Mar 19, 2021
1f78390
Add PlexMovieItem class
glensc Mar 19, 2021
23137cb
Handle xbmcnfo type
glensc Mar 19, 2021
8e8cf40
Replace tmdb alias
glensc Mar 19, 2021
85cc150
Handle old imdb id guid
glensc Mar 19, 2021
ca154cc
Add guid_is_imdb_legacy helper
glensc Mar 19, 2021
8cad068
Add items method
glensc Mar 19, 2021
378f2f9
Add guid property to handle old/new .guid, .guids
glensc Apr 5, 2021
1a4dadf
Add length magic property to PlexLibrarySection
glensc Apr 5, 2021
670f199
Use PlexLibrarySection in process_movie_section process
glensc Apr 5, 2021
b0eb3f2
Merge pull request #174 from glensc/section-wrapper
glensc Apr 5, 2021
fab63f5
Fix guid access typo
glensc Apr 5, 2021
5619e09
Move decorators each on their own file
glensc Apr 5, 2021
b02d384
Merge pull request #175 from glensc/decors-ns
glensc Apr 5, 2021
8e01d70
Add rate_limit decorator
glensc Apr 5, 2021
c8f2aa2
Rate limit all trakt api methods
glensc Apr 5, 2021
0001ec7
Add more details on rate limit logs
glensc Apr 5, 2021
07498dd
Merge pull request #176 from glensc/rate-limit-decorator
glensc Apr 5, 2021
de9c0e5
Add find_movie trakt api method
glensc Apr 5, 2021
74f068b
Catch separately wrong id_type
glensc Mar 20, 2021
9b3c909
find_movie can't be hashable
glensc Apr 5, 2021
a114705
Apply rate_limit decorator to find_movie
glensc Apr 5, 2021
c0f7e8e
Use trakt_api.find_movie to find movie
glensc Apr 5, 2021
c4757be
Merge pull request #178 from glensc/find-movie
glensc Apr 5, 2021
3edd8ff
Add rate limit delay support
glensc Apr 5, 2021
c1fdb9f
Skip initial delay
glensc Apr 5, 2021
a4093eb
Rate limit me for test
glensc Apr 5, 2021
b31fbe4
Add TRAKT_POST_DELAY constant
glensc Apr 5, 2021
d98cd0b
Merge pull request #177 from glensc/rate-limit-delay
glensc Apr 5, 2021
392f652
Move plex_server logic to separate module
glensc Apr 5, 2021
565d97d
Rewrite nocache as function to support decorators on class method arg…
glensc Apr 5, 2021
92ec606
Merge pull request #183 from glensc/nocache-decorator-method-parameters
glensc Apr 5, 2021
52401be
Trakt: Add method to get rating
glensc Mar 19, 2021
c073cc8
Trakt: Add method to add ratings
glensc Mar 20, 2021
2e6922e
Plex: Add method to get rating
glensc Mar 19, 2021
4dabb9d
Plex: Add method to add ratings
glensc Apr 5, 2021
ce5d32f
Sync ratings using Plex/Trakt API classes
glensc Apr 5, 2021
27a620b
Merge pull request #180 from glensc/sync-ratings
glensc Apr 5, 2021
bcf198c
Merge pull request #181 from glensc/plex_server
glensc Apr 5, 2021
f3f8795
Move clear_collections to own commands module
glensc Apr 5, 2021
4e6475c
Pass arguments to main.py
glensc Apr 5, 2021
e080a8d
Allow calling plex_trakt_sync.sh from any directory
glensc Apr 5, 2021
d526a79
Do not reset PATH
glensc Apr 5, 2021
79c1678
Rename movie_collection->movie_collection_set to avoid ambiguity
glensc Apr 5, 2021
cb585ee
Add movie_collection method
glensc Apr 5, 2021
b7cc445
Add remove_from_library method
glensc Apr 5, 2021
978cfe9
Add show_collection method
glensc Apr 5, 2021
c629a57
Move clear_trakt_collections logic to commands/clear_collections
glensc Apr 5, 2021
2aca662
Add --dry-run option to clear_collections command
glensc Apr 5, 2021
27c91cf
Check for valid media type
glensc Apr 5, 2021
c4073a6
Merge pull request #185 from glensc/clear_collections
glensc Apr 6, 2021
15638b7
Merge pull request #184 from glensc/main-wrapper
glensc Apr 6, 2021
6f8b6d5
Cleanups
glensc Apr 6, 2021
a4fcb48
Rename delay to seconds to avoid variable shadowing
glensc Apr 5, 2021
b3dfb24
Add missing guid variable
glensc Apr 6, 2021
becb27b
Plex: Add seen_date property
glensc Mar 20, 2021
59157a1
Plex: Add mark_watched method
glensc Mar 20, 2021
5bd266d
Sync watched using our Plex/Trakt api
glensc Apr 6, 2021
0910f60
Throw ValueError if lastViewedAt is accessed but not set
glensc Apr 6, 2021
ae45c64
Add mark_watched method to TraktApi
glensc Apr 6, 2021
91266b3
Merge pull request #186 from glensc/sync-watched
glensc Apr 6, 2021
d21074a
Add add_to_collection proxy method
glensc Apr 6, 2021
e2af557
Use our Plex/Trakt api to sync collections
glensc Apr 6, 2021
23bdbe8
Add module for listening Plex events
glensc Mar 20, 2021
b3a9fcb
Add watch command to listen for Plex events
glensc Mar 20, 2021
7de7b1c
Rename plex_server to just plex
glensc Apr 6, 2021
435e81d
Add --sync={all|tv|movies} option
glensc Apr 6, 2021
abbf667
Add usage to readme
glensc Apr 6, 2021
e72c6f8
Listen for Play events and print them
glensc Mar 20, 2021
076ef54
Merge pull request #148 from glensc/event-listener
glensc Apr 6, 2021
b938b89
Add fetch_item method
glensc Apr 6, 2021
3119dd8
Wrap response to PlexLibraryItem
glensc Apr 6, 2021
f31bcd9
Add watch_progress method
glensc Apr 6, 2021
be2d452
Add scrobble method
glensc Apr 6, 2021
244a758
Update scrobbling when playing movie
glensc Apr 6, 2021
c42470c
Refactor logic to smaller methods
glensc Apr 6, 2021
17a65f4
Add logger to log received packets
glensc Apr 6, 2021
0475cfe
Filter playing/stopped
glensc Apr 6, 2021
24b5872
Add scrobbler_update method
glensc Apr 6, 2021
42d0975
Keep track of play state, stop scrobbling on stop
glensc Apr 6, 2021
4d29329
Add scrobbler_pause,scrobbler_stop methods
glensc Apr 6, 2021
73e584c
Track paused state
glensc Apr 6, 2021
0dcd6a6
Merge pull request #188 from glensc/sync-collection
glensc Apr 6, 2021
bc5b061
Merge pull request #191 from glensc/sync-option
glensc Apr 6, 2021
a3f2e4e
Implement movies sync into sync command
glensc Mar 20, 2021
985aa9d
Cleanup unused process_movie_section from main.py
glensc Apr 6, 2021
4a547ad
Merge pull request #192 from glensc/scrobbling-listener
glensc Apr 6, 2021
f647c82
Merge pull request #194 from glensc/sync-movies
glensc Apr 6, 2021
91a5a97
Include logger name to log messages
glensc Apr 6, 2021
2e50eb9
Export named logger instance
glensc Apr 6, 2021
4b8fd71
Use named logger
glensc Apr 6, 2021
d17ab78
Fix requests_cache import for trakt_list_util
glensc Apr 6, 2021
ff12857
Import logger as logging in main.py
glensc Apr 6, 2021
10bd587
Merge pull request #193 from glensc/logging
glensc Apr 6, 2021
1ac61ed
Fix py 3.7 compatibility
glensc Apr 6, 2021
2e68684
Merge pull request #196 from glensc/py-3.7
glensc Apr 6, 2021
3d943a0
Ensure find_movie is memoized
glensc Apr 6, 2021
50ac0aa
Replace scrobbler* methods with returning ScrobblerProxy instance
glensc Apr 6, 2021
0ac1d12
Use POST rate limit
glensc Apr 6, 2021
0ed5edf
Add ScrobblerCollection for tracking scrobber instances
glensc Apr 6, 2021
49084d2
Update last_time when rate limiting POST requests
glensc Apr 6, 2021
0ad4108
Add PLEX_PLATFORM constant
glensc Apr 6, 2021
0ae43a9
Use PLEX_PLATFORM constant
glensc Apr 6, 2021
8d1c270
Merge pull request #199 from glensc/X_PLEX_PLATFORM
glensc Apr 6, 2021
e582910
Merge pull request #198 from glensc/rate-limit-fix
glensc Apr 7, 2021
3898b32
Merge pull request #197 from glensc/scrollber-update
glensc Apr 7, 2021
ed90c4b
Merge pull request #179 from glensc/copyrighty from master
glensc Apr 7, 2021
0c8ebcf
Remove unneeded POST delay from trakt.me method
glensc Apr 7, 2021
ee7e629
Replace thetvdb to tvdb
glensc Apr 6, 2021
8a07d03
Update find_movie error to include what is wrong id_type value
glensc Apr 6, 2021
9fc9cb7
Catch JSONDecodeError before ValueError
glensc Apr 7, 2021
586dbce
Merge pull request #203 from glensc/errors
glensc Apr 7, 2021
d6f5314
Ensure ratingKey is passed as int
glensc Apr 6, 2021
7c681b2
Allow int or str for fetch_item
glensc Apr 6, 2021
74c3ea4
Add method to clear cache and reload item
glensc Apr 6, 2021
c23b3fc
Add media_type property to PlexLibraryItem
glensc Apr 7, 2021
9a25f0d
Update find_movie to find also shows
glensc Apr 7, 2021
1cb587b
Merge pull request #205 from glensc/find-media-tv
glensc Apr 7, 2021
817a264
Merge pull request #202 from glensc/tvdb
glensc Apr 7, 2021
00cfd43
Rename sync_movies to for_each_pair to support shows
glensc Apr 7, 2021
d705b7f
Trakt: Add collected and lookup methods
glensc Apr 7, 2021
5d06e61
Move TV shows sync logic to sync command
glensc Apr 7, 2021
6126319
Drop unused process_show_section from main.py
glensc Apr 7, 2021
387ffb2
Merge pull request #204 from glensc/reload-cache
glensc Apr 8, 2021
6653ba8
Merge pull request #201 from glensc/no-post-limit
glensc Apr 8, 2021
e578129
Merge pull request #206 from glensc/tv-shows-sync
glensc Apr 8, 2021
aaf4362
Fix trakt username display on startup
glensc Apr 10, 2021
aa433c6
Merge pull request #221 from glensc/fix-usrename
glensc Apr 10, 2021
dde0666
Match just plex:// prefix, to match also non-movies
glensc Apr 10, 2021
7fdb7b6
Include guid into invalid id_type error
glensc Apr 10, 2021
f37fe21
Setup tests/__init__.py for tests
glensc Apr 10, 2021
adc1074
Use property type to check media type
glensc Apr 10, 2021
f1f4a41
Test parsing of new tv agent
glensc Apr 10, 2021
57b280f
Include original error into ValueError
glensc Apr 10, 2021
afc7118
Add tv.plex.agents.none fix
glensc Apr 10, 2021
7725133
Add test for tv.plex.agents.none
glensc Apr 10, 2021
bc8a6c9
Include media.item.guids detail for future troubleshoot
glensc Apr 10, 2021
14db09a
Merge pull request #222 from glensc/tv-agent-sync-fix
glensc Apr 11, 2021
7882a7e
Add error catching of NotFound plex items
glensc Apr 11, 2021
16b9719
Add guids property
glensc Apr 11, 2021
cbb3629
Catch early on a valid provider
glensc Apr 11, 2021
708fd62
Merge pull request #223 from glensc/skip-erroring-plex-item
glensc Apr 11, 2021
f70c85e
Move sleeping messages to debug log level
glensc Apr 12, 2021
b1413ac
Merge pull request #229 from glensc/sleep-debug
glensc Apr 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
/*
!/*.py
!/Pipfile
!/Pipfile.lock
!/config.default.json
!/plex_trakt_sync/*.py
54 changes: 54 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Contributing to PlexTraktSync

We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer

## We Develop with GitHub

We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.

## We Use [GitHub Flow], So All Code Changes Happen Through Pull Requests

Pull requests are the best way to propose changes to the codebase (we use [GitHub Flow]). We actively welcome your pull requests:

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. Issue that pull request!

[GitHub Flow]: https://guides.github.com/introduction/flow/index.html

## Any contributions you make will be under the MIT Software License

In short, when you submit code changes, your submissions will be understood
under the same [MIT License] that covers the project.

Feel free to contact the maintainers if that's a concern.

[MIT License]: http://choosealicense.com/licenses/mit/

## Report bugs using GitHub's [issues]

We use GitHub issues to track public bugs. Report a bug by [opening a new issue]; it's that easy!

[issues]: https://github.com/Taxel/PlexTraktSync/issues
[opening a new issue]: https://github.com/Taxel/PlexTraktSync/issues/new

## License

By contributing, you agree that your contributions will be licensed under its MIT License.

## References

This document was adapted from [@briandk gist] which itself was adapted from
the open-source contribution guidelines for [Facebook's Draft].

[@briandk gist]: https://gist.github.com/briandk/3d2e8b3ec8daf5a27a62
[Facebook's Draft]: https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.9-alpine3.13 AS base

WORKDIR /app
ENTRYPOINT ["/app/main.py"]

# Install app depedencies
RUN pip install pipenv
COPY Pipfile* ./
RUN pipenv install --system --deploy

# Copy rest of the app
COPY . .
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ verify_ssl = true
[dev-packages]

[packages]
click = "==7.1.2"
plexapi = "==4.5.0"
python-dotenv = "==0.15.0"
requests-cache = "==0.5.2"
trakt = "==3.0.0"
plexapi = "==4.5.0"

[requires]
python_version = "3"
10 changes: 9 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ type `crontab -e` in the terminal.
0 */2 * * * cd ~/path/to/this/repo && ./plex_trakt_sync.sh
```

## Sync options

The sync subcommand supports `--sync=tv` and `--sync=movies` options,
so you can sync only specific library types.

```
➔ ./plex_trakt_sync.sh sync --help
Usage: main.py sync [OPTIONS]

Perform sync between Plex and Trakt

Options:
--sync [all|movies|tv] Specify what to sync [default: all]
--help Show this message and exit.
```

## Sync settings

To disable parts of the functionality of this software, look no further than
Expand Down
6 changes: 0 additions & 6 deletions clear_trakt_collections.py

This file was deleted.

4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

from plex_trakt_sync.main import main
from plex_trakt_sync.cli import cli

if __name__ == "__main__":
main()
cli()
7 changes: 5 additions & 2 deletions plex_trakt_sync.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/sh
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin
python3 ./main.py
set -eu

dir=$(dirname "$0")

exec python3 "$dir/main.py" "$@"
15 changes: 0 additions & 15 deletions plex_trakt_sync/clear_trakt_collections.py

This file was deleted.

19 changes: 19 additions & 0 deletions plex_trakt_sync/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import click
from plex_trakt_sync.commands.clear_collections import clear_collections
from plex_trakt_sync.commands.sync import sync
from plex_trakt_sync.commands.watch import watch


@click.group(invoke_without_command=True)
@click.pass_context
def cli(ctx):
"""
Plex-Trakt-Sync is a two-way-sync between trakt.tv and Plex Media Server
"""
if not ctx.invoked_subcommand:
sync()


cli.add_command(sync)
cli.add_command(clear_collections)
cli.add_command(watch)
28 changes: 28 additions & 0 deletions plex_trakt_sync/commands/clear_collections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import click
from plex_trakt_sync.logging import logger
from plex_trakt_sync.trakt_api import TraktApi


@click.command()
@click.option('--confirm', is_flag=True, help='Confirm the dangerous action')
@click.option('--dry-run', is_flag=True, help='Do not perform delete actions')
def clear_collections(confirm, dry_run):
"""
Clear Movies and Shows collections in Trakt
"""

if not confirm and not dry_run:
click.echo('You need to pass --confirm or --dry-run option to proceed')
return

trakt = TraktApi()

for movie in trakt.movie_collection:
logger.info(f"Deleting: {movie}")
if not dry_run:
trakt.remove_from_library(movie)

for show in trakt.show_collection:
logger.info(f"Deleting: {show}")
if not dry_run:
trakt.remove_from_library(show)
Loading