mirror of
https://github.com/pkkid/python-plexapi
synced 2025-02-16 21:08:27 +00:00
revert NA to _NA so its still compat with the tests.
- this allows for casting str and check for __NA__ in addition to is instance. - some indentation fixes
This commit is contained in:
parent
8d8eeb4faa
commit
d19d602455
3 changed files with 25 additions and 25 deletions
|
@ -279,8 +279,6 @@ class Track(Audio, Playable):
|
|||
for e in data if e.tag == media.Media.TYPE]
|
||||
if self.isFullObject(): # check me
|
||||
self.moods = [media.Mood(self.server, e) for e in data if e.tag == media.Mood.TYPE]
|
||||
self.media = [media.Media(self.server, e, self.initpath, self) for e in data if e.tag == media.Media.TYPE]
|
||||
|
||||
#self.media = [media.Media(self.server, e, self.initpath, self)
|
||||
# for e in data if e.tag == media.Media.TYPE]
|
||||
# data for active sessions and history
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from plexapi import log, utils
|
||||
from plexapi import X_PLEX_CONTAINER_SIZE
|
||||
from plexapi import X_PLEX_CONTAINER_SIZE, log, utils
|
||||
from plexapi.compat import unquote
|
||||
from plexapi.media import MediaTag
|
||||
from plexapi.exceptions import BadRequest, NotFound
|
||||
from plexapi.media import MediaTag
|
||||
|
||||
|
||||
class Library(object):
|
||||
|
@ -71,6 +70,7 @@ class Library(object):
|
|||
Parameters:
|
||||
sectionID (int): ID of the section to return.
|
||||
"""
|
||||
if not self._sectionsByID or sectionID not in self._sectionsByID:
|
||||
self.sections()
|
||||
return self._sectionsByID[sectionID]
|
||||
|
||||
|
@ -95,8 +95,8 @@ class Library(object):
|
|||
title (str): Title of the item to return.
|
||||
"""
|
||||
for i in self.all():
|
||||
if i.title.lower() == tite.lower():
|
||||
reutrn i
|
||||
if i.title.lower() == title.lower():
|
||||
return i
|
||||
|
||||
def getByKey(self, key):
|
||||
""" Return the first item from all items with the specified key.
|
||||
|
@ -135,7 +135,6 @@ class Library(object):
|
|||
# Should this return true or false?
|
||||
# check element if if has the correct mediaprefix?
|
||||
|
||||
|
||||
def emptyTrash(self):
|
||||
""" If a library has items in the Library Trash, use this option to empty the Trash. """
|
||||
for section in self.sections():
|
||||
|
@ -381,9 +380,9 @@ class MovieSection(LibrarySection):
|
|||
TYPE (str): 'movie'
|
||||
"""
|
||||
ALLOWED_FILTERS = ('unwatched', 'duplicate', 'year', 'decade', 'genre', 'contentRating',
|
||||
'collection', 'director', 'actor', 'country', 'studio', 'resolution')
|
||||
'collection', 'director', 'actor', 'country', 'studio', 'resolution')
|
||||
ALLOWED_SORT = ('addedAt', 'originallyAvailableAt', 'lastViewedAt', 'titleSort', 'rating',
|
||||
'mediaHeight', 'duration')
|
||||
'mediaHeight', 'duration')
|
||||
TYPE = 'movie'
|
||||
|
||||
|
||||
|
@ -399,7 +398,7 @@ class ShowSection(LibrarySection):
|
|||
"""
|
||||
ALLOWED_FILTERS = ('unwatched', 'year', 'genre', 'contentRating', 'network', 'collection')
|
||||
ALLOWED_SORT = ('addedAt', 'lastViewedAt', 'originallyAvailableAt', 'titleSort',
|
||||
'rating', 'unwatched')
|
||||
'rating', 'unwatched')
|
||||
TYPE = 'show'
|
||||
|
||||
def searchShows(self, **kwargs):
|
||||
|
@ -473,7 +472,6 @@ class PhotoSection(LibrarySection):
|
|||
return [i for i in photos if i.title.lower() == title.lower()]
|
||||
|
||||
|
||||
|
||||
@utils.register_libtype
|
||||
class FilterChoice(object):
|
||||
""" Represents a single filter choice. These objects are gathered when using filters
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import logging, re
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime
|
||||
from plexapi.compat import quote, urlencode, string_type
|
||||
from threading import Thread
|
||||
|
||||
import requests
|
||||
|
||||
from plexapi.exceptions import NotFound, UnknownType, Unsupported
|
||||
|
||||
from plexapi.compat import quote, string_type, urlencode
|
||||
from plexapi.exceptions import NotFound, NotImplementedError, UnknownType, Unsupported
|
||||
from threading import Thread
|
||||
#from plexapi import log
|
||||
|
||||
|
||||
# Search Types - Plex uses these to filter specific media types when searching.
|
||||
|
@ -28,7 +31,7 @@ def register_libtype(cls):
|
|||
return cls
|
||||
|
||||
|
||||
class NA(object):
|
||||
class _NA(object):
|
||||
""" This used to be a simple variable equal to '__NA__'. There has been need to
|
||||
compare NA against None in some use cases. This object allows the internals
|
||||
of PlexAPI to distinguish between unfetched values and fetched, but non-existent
|
||||
|
@ -39,7 +42,7 @@ class NA(object):
|
|||
return False
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, NA) or other in [None, '__NA__']
|
||||
return isinstance(other, _NA) or other in [None, '__NA__']
|
||||
|
||||
def __nonzero__(self):
|
||||
return False
|
||||
|
@ -48,6 +51,10 @@ class NA(object):
|
|||
return '__NA__'
|
||||
|
||||
|
||||
# Lets do this for now.
|
||||
NA = _NA()
|
||||
|
||||
|
||||
class SecretsFilter(logging.Filter):
|
||||
""" Logging filter to hide secrets. """
|
||||
def __init__(self, secrets=None):
|
||||
|
@ -446,8 +453,7 @@ def listItems(server, path, libtype=None, watched=None, bytag=False):
|
|||
return items
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
def rget(obj, attrstr, default=None, delim='.'):
|
||||
def rget(obj, attrstr, default=None, delim='.'): # pragma: no cover
|
||||
""" Returns the value at the specified attrstr location within a nexted tree of
|
||||
dicts, lists, tuples, functions, classes, etc. The lookup is done recursivley
|
||||
for each key in attrstr (split by by the delimiter) This function is heavily
|
||||
|
@ -459,9 +465,6 @@ def rget(obj, attrstr, default=None, delim='.'):
|
|||
default (any): Default value to return if not found.
|
||||
delim (str): Delimiter separating keys in attrstr.
|
||||
"""
|
||||
=======
|
||||
def rget(obj, attrstr, default=None, delim='.'): # pragma: no cover # Dont think its is used
|
||||
>>>>>>> more cov
|
||||
try:
|
||||
parts = attrstr.split(delim, 1)
|
||||
attr = parts[0]
|
||||
|
@ -594,9 +597,10 @@ def download(url, filename=None, savepath=None, session=None, chunksize=4024, mo
|
|||
if chunk:
|
||||
f.write(chunk)
|
||||
|
||||
log.debug('Downloaded %s to %s from %s' % (filename, fullpath, url))
|
||||
#log.debug('Downloaded %s to %s from %s' % (filename, fullpath, url))
|
||||
|
||||
return fullpath
|
||||
|
||||
except Exception as e: # pragma: no cover
|
||||
log.exception('Failed to download %s to %s %s' % (url, fullpath, e))
|
||||
print('e %s' % e)
|
||||
#log.exception('Failed to download %s to %s %s' % (url, fullpath, e))
|
||||
|
|
Loading…
Add table
Reference in a new issue