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

Add support for custom userlists, export format, requirements, and more #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
160 changes: 70 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,125 +1,105 @@
# Trakt.tv import/export tools
# trakt.tv import/export tools

## Purpose
Python scripts that use the [Trakt API](https://trakt.docs.apiary.io/) to export movie and episodes from trakt lists to a csv file, and import them back to any Trakt account.

* Import Movies or TVShows IDs from CSV file format into Trakt.tv.
* Export Movies or TVShows IDs from Trakt.tv list into CSV file format.
* Create trakt.tv custom list from TDMB discover with filter.

## Requirements
## Installation

You must use Python 3.x.

### On Ubuntu/Debian Linux system

Ensure you are running Python 3
```
$ python -V
Python 3.5
```

Install need module dependencies
To install requirements:

```
$ apt-get install python3-dateutil python3-simplejson python3-requests python3-openssl jq
```

### On Arch/Manjaro Linux system

Install dependencies with pacman

```
$ pacman -S python python-dateutil python-simplejson python-requests python-pyopenssl jq
```console
$ pip install -r requirements.txt
```

### On Windows system
## Usage

Download the installer: https://www.python.org/downloads/windows/
### Setup

Ensure you are running Python 3
* Create an [Trakt.tv application](https://trakt.tv/oauth/applications) to have your own ``client_id`` and ``client_secret``, https://trakt.tv/oauth/applications.
You only need to fill up the ``Name`` with a ``Description`` and ``Redirect uri`` to `urn:ietf:wg:oauth:2.0:oob`, leave the rest empty and click on ``SAVE APP``.
* Run the script to create a default config file ``config.ini``
```
<python dir>>python.exe -V
Python 3.5
$ python export_trakt.py
```

Install need module dependencies

* Edit the config file ``config.ini``. You **must** specify
* ``client_id``
* ``client_secret``
* ``username``
* any other settings appropriate to your environment, eg: URL, proxy, etc...
* Run the script to authenticate against Trakt.tv API using the PIN method.
```
<python dir>\Scripts\pip3.exe install requests simplejson
$ python export_trakt.py
```
* In the CLI, you will be prompted to open a link into a browser and paste the pincode back to the script. You should only need to do this once.

### On macOS system

Download the installer: https://www.python.org/downloads/mac-osx/

Append to PATH in ZSH
### Import

```shell
$ path=('/Library/Frameworks/Python.framework/Versions/3.8/bin' $path)
For help, run
```console
$ python import_trakt.py -h
```

Ensure you are running Python 3

```shell
$ python3 -V
Python 3.8.5
#### Import movies from csv file to history with csv ``watched_at`` time
The following command will import all movies in ``m.csv`` to the default history list in Trakt with the ``watched_at`` and the ``trakt`` id columns specified in ``m.csv``.
```console
$ python import_trakt.py -c config.ini -f trakt -i m.csv -l history -t movies -w
```

Run Install Certificates.command

```shell
$ pip3 install certifi
#### Import episodes from csv file to history with custom ``watched_at`` time
The following command will import all episodes in ``e.csv`` to the default history list in Trakt with the ``trakt`` id columns specified in ``e.csv``, with a ``watched_at`` date set to ``2014-01-01T00:00:00.000Z``.
```console
$ python import_trakt.py -c config.ini -f trakt -i e.csv -l history -t episodes -s 2014-01-01T00:00:00.000Z
```

Open a new Terminal session so that certificates will be available

Install need module dependencies

```shell
$ pip3 install python-dateutil
$ pip3 install simplejson
$ pip3 install requests
$ pip3 install pyopenssl
$ pip3 install jq
#### Import movies from csv file to user list
The following command will import all movies in ``m.csv`` to a custom user list using the ``trakt`` id columns specified in ``m.csv``.
```console
$ python import_trakt.py -c config.ini -f trakt -i m_f.csv -t movies -u
```

## Usage
The user will have to provide the id of the user list they want to import to.
```console
Found 2 user list(s)

* Create an [Trakt.tv application](https://trakt.tv/oauth/applications) to have your own ``client_id`` and ``client_secret``, https://trakt.tv/oauth/applications.
You only need to fill up the ``Name`` with a ``Description`` and ``Redirect uri`` to `urn:ietf:wg:oauth:2.0:oob`, leave the rest empty and click on ``SAVE APP``.
id | name
21358741 | test2
21369802 | test

* Run the script to create a default config file ``config.ini``

```
$ python export_trakt.py
Type in the id matching with the name of the list you want to import item(s) to.
Input:
```

* Edit the config file ``config.ini`` and specify the ``client_id`` and ``client_secret`` as well as any other settings appropriate to your enviromenent, eg: URL, proxy, etc...
Refer to ``Configuration details`` section for more information.
### Export

For help, run
```console
$ python export_trakt.py -h
```
$ vim config.ini
#### Export movies from history list to csv
The following command will export all movies in Trakt's default history list to ``m.csv``.
```console
$ python export_trakt.py -c config.ini -t movies -o m.csv -l history
```

* Run the script to authenticate against Trakt.tv API using the PIN method and it will generate you an ``oauth_token``.
You will be prompted to open a link into a browser and paste the pincode back to the script.
Make sure you save the generated ``oauth_token`` into the config file ``config.ini`` for later use.

#### Export episodes from history list to csv
The following command will export all episodes in Trakt's default history list to ``e.csv``.
```console
$ python export_trakt.py -c config.ini -t episodes -o e.csv -l history
```
$ python export_trakt.py
#### Export user list to csv
The following command will export all movies from a custom user list to ``test2.csv``.
```console
$ python export_trakt.py -c config.ini -t movies -o test2.csv -u
```

## Import

[Import CSV into trakt.tv](import.md)

## Export
The user will have to provide the id of the user list they want to export, or ``all`` for all user lists. This will export them in to csv files with the name of the user list.
```console
Found 2 user list(s)

[Export data from trakt.tv into CSV](export.md)
id | name
21358741 | test2
21369802 | test

## Sync

[Create trakt.tv list from TDMB discover with filter](sync.md)
Type in the id matching with the name of the list you want to export, or 'all' for all lists.
Input:
```

## Export data from Kodi

Expand All @@ -138,7 +118,7 @@ To get support, please create new [issue](https://github.com/xbgmsharp/trakt/iss
## Contribution
I'm happy to accept Pull Requests!

## Licence
## License

This script is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation.

Expand Down
Loading