Skip to content

Commit

Permalink
Merge pull request #209 from Taxel/main
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Apr 17, 2021
2 parents 69634a9 + b1413ac commit 72bb5ed
Show file tree
Hide file tree
Showing 31 changed files with 1,120 additions and 508 deletions.
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

0 comments on commit 72bb5ed

Please sign in to comment.