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

2.4.0 Filter/Subfilter Overall, tmdb_director, and tmdb_writer #76

Merged
merged 36 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
656bde3
Merge pull request #5 from mza921/master
meisnate12 Oct 27, 2020
d206f7b
Bump pyyaml from 5.1.2 to 5.3.1
dependabot[bot] Oct 27, 2020
cf43b95
Merge pull request #7 from mza921/master
meisnate12 Oct 28, 2020
1faee56
Merge pull request #6 from meisnate12/dependabot/pip/pyyaml-5.3.1
meisnate12 Oct 28, 2020
cc8e0d5
added method to detail
meisnate12 Oct 28, 2020
7ed0018
combined methods
meisnate12 Oct 28, 2020
51496a7
update trakt_tools
meisnate12 Oct 28, 2020
e6cb027
Merge pull request #8 from mza921/master
meisnate12 Oct 28, 2020
d7d4c68
method rename
meisnate12 Oct 29, 2020
be0a1e1
2.3.0 Revamped Filters and Subfilters
meisnate12 Oct 29, 2020
878a7c3
typo
meisnate12 Oct 29, 2020
392b12e
fixed two errors
meisnate12 Oct 29, 2020
405b6d1
added tmdb_director
meisnate12 Oct 29, 2020
0e2d05f
collection_sort -> collection_order
meisnate12 Oct 30, 2020
5f65bdb
updated CHANGELOG
meisnate12 Oct 30, 2020
9d60c0f
added tmdb_writer
meisnate12 Oct 30, 2020
7b63417
README fix
meisnate12 Oct 30, 2020
22e10a7
README edit
meisnate12 Oct 30, 2020
d79a628
days_from_now -> max_age
meisnate12 Oct 30, 2020
1c19c88
! -> .not
meisnate12 Oct 30, 2020
0827293
check methods first
meisnate12 Oct 30, 2020
47aee95
small fixes
meisnate12 Oct 30, 2020
fe62ae6
Overhaul how the program checks input and .and
meisnate12 Oct 31, 2020
425c881
bug fix
meisnate12 Oct 31, 2020
f741f34
filters->searches subfilters->collection_filters
meisnate12 Nov 1, 2020
d31f169
Bump plexapi from 4.1.2 to 4.2.0
dependabot[bot] Nov 2, 2020
208ffcf
Major Config checks created plex_search
meisnate12 Nov 3, 2020
c57b78b
Merge pull request #9 from meisnate12/dependabot/pip/plexapi-4.2.0
meisnate12 Nov 3, 2020
0b4617b
Bump plexapi from 4.1.2 to 4.2.0
meisnate12 Nov 3, 2020
24a4c7b
README edits
meisnate12 Nov 3, 2020
22ddd65
README fix
meisnate12 Nov 3, 2020
c44982a
typo
meisnate12 Nov 3, 2020
40dba4a
removed decade and fixed bug
meisnate12 Nov 3, 2020
7b14b7a
Merge remote-tracking branch 'upstream/master'
meisnate12 Nov 3, 2020
d53c3c8
decades is back
meisnate12 Nov 4, 2020
b38f082
Merge remote-tracking branch 'upstream/master'
meisnate12 Nov 4, 2020
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.0] - 2020-11-01
### Added
- Added `and.` to AND searches together instead of OR
- Added additional `collection_filters` and allow for use of `.not` with `collection_filters`
- Added `tmdb_director` and `tmdb_writer` which function the same as `tmdb_actor` but for directors and writers

### Changed
- `Filters` are now listed and have been tested and have been changed to `Searches`
- `Subfilters` are now listed and have been tested and have been changed to `collection_filters`

### Fixed
- `collection_order` was in the code as `collection_sort`

## [2.2.1] - 2020-10-28
### Added
- CHANGELOG.md
Expand Down
214 changes: 170 additions & 44 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/config_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def check_for_attribute(config, attribute, parent=None, test_list=None, options=
message = message + " using {} as default".format(default)
message = message + endline
if (default is None and not default_is_none) or throw:
if len(options) > 0 and not throw:
if len(options) > 0:
message = message + "\n" + options
sys.exit(message)
if do_print:
Expand Down
53 changes: 15 additions & 38 deletions app/imdb_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def imdb_get_movies(config_path, plex, data):
tree = html.fromstring(r.content)
title_ids.extend(tree.xpath("//div[contains(@class, 'lister-item-image')]"
"//a/img//@data-tconst"))
matched_imbd_movies = []
matched_imdb_movies = []
missing_imdb_movies = []
if title_ids:
for m in plex.Library.all():
Expand All @@ -80,31 +80,15 @@ def imdb_get_movies(config_path, plex, data):
for imdb_id in title_ids:
movie = imdb_map.pop(imdb_id, None)
if movie:
matched_imbd_movies.append(plex.Server.fetchItem(movie.ratingKey))
matched_imdb_movies.append(plex.Server.fetchItem(movie.ratingKey))
else:
missing_imdb_movies.append(imdb_id)

return matched_imbd_movies, missing_imdb_movies

def tmdb_parse_id(data):
try:
tmdb_id = re.search('.*?(\\d+)', str(data)) # re.search requires a string
tmdb_id = tmdb_id.group(1)
return tmdb_id
except AttributeError: # Bad URL Provided
raise ValueError("| Config Error: TMDb ID: {} is invalid it must be a number".format(data))

def tvdb_parse_id(data):
try:
tvdb_id = re.search('(\\d+)', str(data)) # re.search requires a string
tvdb_id = tvdb_id.group(1)
return tvdb_id
except AttributeError:
raise ValueError("| Config Error: TVDb ID: {} is invalid it must be a number".format(data))
return matched_imdb_movies, missing_imdb_movies


def tmdb_get_movies(config_path, plex, data, is_list=False):
tmdb_id = tmdb_parse_id(data)
tmdb_id = int(data)
t_movs = []
t_movie = Movie()
t_movie.api_key = config_tools.TMDB(config_path).apikey # Set TMDb api key for Movie
Expand Down Expand Up @@ -177,14 +161,9 @@ def tmdb_get_movies(config_path, plex, data, is_list=False):

def get_tautulli(config_path, plex, data):
tautulli = config_tools.Tautulli(config_path)
list_type = config_tools.check_for_attribute(data, "list_type", parent="tautulli", test_list=["popular", "watched"], options="| \tpopular (Most Popular List)\n| \twatched (Most Watched List)", throw=True, save=False)
time_range = config_tools.check_for_attribute(data, "list_days", parent="tautulli", var_type="int", default=30, save=False)
max = config_tools.check_for_attribute(data, "list_size", parent="tautulli", var_type="int", default=10, save=False)
buffer = config_tools.check_for_attribute(data, "list_buffer", parent="tautulli", var_type="int", default=20, save=False)
stats_count = max + buffer

response = requests.get("{}/api/v2?apikey={}&cmd=get_home_stats&time_range={}&stats_count={}".format(tautulli.url, tautulli.apikey, time_range, stats_count)).json()
stat_id = ("popular" if list_type == "popular" else "top") + "_" + ("movies" if plex.library_type == "movie" else "tv")
response = requests.get("{}/api/v2?apikey={}&cmd=get_home_stats&time_range={}&stats_count={}".format(tautulli.url, tautulli.apikey, data["list_days"], int(data["list_size"]) + int(data["list_buffer"]))).json()
stat_id = ("popular" if data["list_type"] == "popular" else "top") + "_" + ("movies" if plex.library_type == "movie" else "tv")

items = None
for entry in response['response']['data']:
Expand All @@ -207,7 +186,7 @@ def get_tautulli(config_path, plex, data):
missing = []
count = 0
for item in items:
if item['section_id'] == section_id and count < max:
if item['section_id'] == section_id and count < int(data["list_size"]):
matched.append(plex.Library.fetchItem(item['rating_key']))
count = count + 1

Expand All @@ -216,18 +195,16 @@ def get_tautulli(config_path, plex, data):
def get_tvdb_id_from_tmdb_id(id):
lookup = trakt.Trakt['search'].lookup(id, 'tmdb', 'show')
if lookup:
if isinstance(lookup, list):
return trakt.Trakt['search'].lookup(id, 'tmdb', 'show')[0].get_key('tvdb')
else:
return trakt.Trakt['search'].lookup(id, 'tmdb', 'show').get_key('tvdb')
lookup = lookup[0] if isinstance(lookup, list) else lookup
return lookup.get_key('tvdb')
else:
return None

def tmdb_get_shows(config_path, plex, data, is_list=False):
config_tools.TraktClient(config_path)
tmdb_id = tmdb_parse_id(data)

tmdb_id = int(data)

t_tvs = []
t_tv = TV()
t_tv.api_key = config_tools.TMDB(config_path).apikey # Set TMDb api key for Movie
Expand Down Expand Up @@ -282,8 +259,8 @@ def tmdb_get_shows(config_path, plex, data, is_list=False):

def tvdb_get_shows(config_path, plex, data, is_list=False):
config_tools.TraktClient(config_path)
id = tvdb_parse_id(data)

id = int(data)

p_tv_map = {}
for item in plex.Library.all():
Expand Down Expand Up @@ -314,7 +291,7 @@ def tvdb_get_shows(config_path, plex, data, is_list=False):

def tmdb_get_summary(config_path, data, type):
# Instantiate TMDB objects
id = tmdb_parse_id(data)
id = int(data)

api_key = config_tools.TMDB(config_path).apikey
language = config_tools.TMDB(config_path).language
Expand Down
Loading