Skip to content

Commit 805a3dc

Browse files
laur89zakkarry
andcommitted
add(wheel/pip): functionality for publishing to pypi (#6)
* fix packaging * setup.py: remove package_dir * add retraktarr.py to project root - allows running directly from source * setup.py: requirements win compatibility fix * add *.txt file to MANIFEST * cleanup: cleanup and --config improvements * update(retraktarr): formatting and console output --------- Co-authored-by: zakary <zak@ary.dev>
1 parent 6b55a6b commit 805a3dc

File tree

12 files changed

+225
-214
lines changed

12 files changed

+225
-214
lines changed

MANIFEST.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
include VERSION
1+
include retraktarr/VERSION
22
include README.md
33
include LICENSE
4+
include *.py
5+
include *.txt
6+
include MANIFEST.in
47
exclude *.conf
58
exclude .git*

__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests

retraktarr.py

Lines changed: 2 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -1,208 +1,4 @@
11
#!/usr/bin/env python3
2-
""" main script, arguments and executions """
3-
import sys
4-
import argparse
5-
from os import name, path, getenv
2+
from retraktarr import main
63

7-
from retraktarr.api.arr import ArrAPI
8-
from retraktarr.api.trakt import TraktAPI
9-
from retraktarr.config import Configuration
10-
11-
12-
try:
13-
with open(
14-
path.join(path.dirname(path.abspath(__file__)), "VERSION"), encoding="utf-8"
15-
) as f:
16-
VERSION = f.read()
17-
except OSError as e:
18-
VERSION = "MISSING"
19-
20-
config_path = f'{path.expanduser("~")}{path.sep}.config{path.sep}retraktarr.conf'
21-
22-
23-
def main():
24-
"""main entry point defines args and processes stuff"""
25-
try:
26-
with open(
27-
path.join(path.dirname(path.abspath(__file__)), "VERSION"), encoding="utf-8"
28-
) as f:
29-
VERSION = f.read()
30-
except OSError as e:
31-
VERSION = "MISSING"
32-
33-
parser = argparse.ArgumentParser(
34-
description="Starr App -> Trakt.tv List Backup/Synchronization"
35-
)
36-
parser.add_argument(
37-
"--oauth",
38-
"-o",
39-
type=str,
40-
help="Update OAuth2 Bearer Token."
41-
" Accepts the auth code and requires valid Trakt "
42-
"config settings (ex: -o CODE_HERE)",
43-
)
44-
parser.add_argument(
45-
"--radarr",
46-
"-r",
47-
action="store_true",
48-
help="Synchronize Radarr movies with Trakt.tv",
49-
)
50-
parser.add_argument(
51-
"--sonarr",
52-
"-s",
53-
action="store_true",
54-
help="Synchronize Sonarr series with Trakt.tv",
55-
)
56-
parser.add_argument(
57-
"--all",
58-
"-all",
59-
"-a",
60-
action="store_true",
61-
help="Synchronize both Starr apps with Trakt.tv",
62-
)
63-
parser.add_argument(
64-
"--mon",
65-
"-m",
66-
action="store_true",
67-
help="Synchronize only monitored content with Trakt.tv",
68-
)
69-
parser.add_argument(
70-
"--qualityprofile",
71-
"-qp",
72-
type=str,
73-
help="The quality profile you wish to sync to Trakt.tv",
74-
)
75-
parser.add_argument(
76-
"--tag", "-t", type=str, help="The arr tag you wish to sync to Trakt.tv"
77-
)
78-
parser.add_argument(
79-
"--cat",
80-
"-c",
81-
action="store_true",
82-
help="Add to the Trakt.tv list without "
83-
"deletion (concatenate/append to list)",
84-
)
85-
parser.add_argument(
86-
"--list",
87-
"-l",
88-
type=str,
89-
help="Specifies the Trakt.tv list name. (overrides config file settings)",
90-
)
91-
parser.add_argument(
92-
"--wipe",
93-
"-w",
94-
action="store_true",
95-
help="Erases the associated list and performs a sync "
96-
"(requires -all or -r/s)",
97-
)
98-
parser.add_argument(
99-
"--privacy",
100-
"-p",
101-
type=str,
102-
help="Specifies the Trakt.tv list privacy settings "
103-
"(private/friends/public - overrides config file settings)",
104-
)
105-
parser.add_argument(
106-
"--refresh",
107-
action="store_true",
108-
help="Forces a refresh_token exchange (oauth) "
109-
"and sets the config to a new tokens.",
110-
)
111-
parser.add_argument(
112-
"--timeout",
113-
type=str,
114-
help="Specifies the timeout in seconds to use for " "POST commands to Trakt.tv",
115-
)
116-
parser.add_argument(
117-
"--version",
118-
action="store_true",
119-
help="Displays current version information",
120-
)
121-
parser.add_argument(
122-
"--config",
123-
type=str,
124-
help="Specifies configuration file",
125-
)
126-
args = parser.parse_args()
127-
128-
if args.version:
129-
print(f"reTraktarr v{VERSION}")
130-
sys.exit(0)
131-
if args.config:
132-
config_path = args.config
133-
else:
134-
config_path = (
135-
f'{path.expanduser("~")}{path.sep}.config{path.sep}retraktarr.conf'
136-
)
137-
print(config_path)
138-
config = Configuration(config_path)
139-
if args.oauth:
140-
config.get_oauth(args)
141-
if args.refresh:
142-
config.get_oauth(args)
143-
144-
(
145-
oauth2_bearer,
146-
trakt_api_key,
147-
trakt_user,
148-
trakt_secret,
149-
) = config.validate_trakt_credentials()
150-
trakt_api = TraktAPI(oauth2_bearer, trakt_api_key, trakt_user, trakt_secret)
151-
if args.list:
152-
trakt_api.list = args.list
153-
if args.privacy:
154-
trakt_api.list_privacy = args.privacy
155-
if args.timeout:
156-
trakt_api.post_timeout = args.timeout
157-
if args.radarr or args.all or args.sonarr:
158-
arr_api = ArrAPI()
159-
160-
if args.radarr or args.all:
161-
config.validate_arr_configuration(arr_api, trakt_api, "Radarr", args)
162-
tvdb_ids, tmdb_ids, imdb_ids, trakt_ids = trakt_api.get_list(
163-
args, arr_api.endpoint["Radarr"][0]
164-
)
165-
arr_ids, arr_imdb, arr_data = arr_api.get_list(args, "Radarr")
166-
trakt_api.add_to_list(
167-
args,
168-
arr_api.endpoint["Radarr"][2],
169-
arr_data,
170-
tmdb_ids,
171-
arr_api.endpoint["Radarr"][1],
172-
imdb_ids,
173-
arr_ids,
174-
arr_imdb,
175-
trakt_ids,
176-
)
177-
print(f"Total Movies: {len(arr_ids)}\n")
178-
179-
if args.sonarr or args.all:
180-
config.validate_arr_configuration(arr_api, trakt_api, "Sonarr", args)
181-
182-
tvdb_ids, tmdb_ids, imdb_ids, trakt_ids = trakt_api.get_list(
183-
args, arr_api.endpoint["Sonarr"][2].rstrip("s")
184-
)
185-
186-
arr_ids, arr_imdb, arr_data = arr_api.get_list(args, "Sonarr")
187-
trakt_api.add_to_list(
188-
args,
189-
arr_api.endpoint["Sonarr"][2],
190-
arr_data,
191-
tvdb_ids,
192-
arr_api.endpoint["Sonarr"][1],
193-
imdb_ids,
194-
arr_ids,
195-
arr_imdb,
196-
trakt_ids,
197-
)
198-
print(f"Total Series: {len(arr_ids)}")
199-
sys.exit(1)
200-
201-
if args.radarr or args.all:
202-
sys.exit(1)
203-
204-
parser.print_help()
205-
206-
207-
if __name__ == "__main__":
208-
main()
4+
main()
File renamed without changes.

retraktarr/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .retraktarr import main
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)