Skip to content

Commit

Permalink
Merge branch 'release/1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzeman committed Feb 16, 2017
2 parents 87dae5c + 1399686 commit a6ab5f4
Show file tree
Hide file tree
Showing 46 changed files with 4,144 additions and 954 deletions.
16 changes: 10 additions & 6 deletions Tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'linux_x86_64': ('Linux', 'x86_64'),

# Mac OSX
'macosx_intel': ('MacOSX', 'i386'),
'macosx_i386': ('MacOSX', 'i386'),
'macosx_x86_64': ('MacOSX', 'x86_64'),

# Windows
Expand Down Expand Up @@ -202,13 +202,17 @@ def compress(self, build_path, name):
if not sha:
return False

# Build release name
filename = '%s.zip' % ('-'.join([
# Build release filename
components = [
RELEASE_NAME,
version,
sha,
name
]))
sha
]

if name != 'universal':
components.append(name)

filename = '%s.zip' % ('-'.join(components))

print(' - Compressing package (filename: %r)...' % filename)

Expand Down
2 changes: 1 addition & 1 deletion Trakttv.bundle/Contents/Code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def init_trakt(cls):
# Http
Trakt.base_url = (
config.get('protocol', 'https') + '://' +
config.get('hostname', 'api-v2launch.trakt.tv')
config.get('hostname', 'api.trakt.tv')
)

Trakt.configuration.defaults.http(
Expand Down
7 changes: 5 additions & 2 deletions Trakttv.bundle/Contents/Libraries/Shared/croniter/croniter.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class croniter(object):
bad_length = 'Exactly 5 or 6 columns has to be specified for iterator' \
'expression.'

def __init__(self, expr_format, start_time=None, ret_type=float):
def __init__(self, expr_format, start_time=None, ret_type=float, day_or=True):
self._ret_type = ret_type
self._day_or = day_or

if start_time is None:
start_time = time()

Expand Down Expand Up @@ -240,7 +242,8 @@ def _get_next(self, ret_type=None, is_prev=False):
raise TypeError("Invalid ret_type, only 'float' or 'datetime' "
"is acceptable.")

if expanded[2][0] != '*' and expanded[4][0] != '*':
# exception to support day of month and day of week as defined in cron
if (expanded[2][0] != '*' and expanded[4][0] != '*') and self._day_or:
bak = expanded[4]
expanded[4] = ['*']
t1 = self._calc(self.cur, expanded, is_prev)
Expand Down
10 changes: 5 additions & 5 deletions Trakttv.bundle/Contents/Libraries/Shared/ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import itertools
import struct

__version__ = '1.0.17'
__version__ = '1.0.18'

# Compatibility functions
_compat_int_types = (int,)
Expand Down Expand Up @@ -58,6 +58,8 @@ def _compat_to_bytes(intval, length, endianess):
return struct.pack(b'!QQ', intval >> 64, intval & 0xffffffffffffffff)
else:
raise NotImplementedError()


if hasattr(int, 'bit_length'):
# Not int.bit_length , since that won't work in 2.7 where long exists
def _compat_bit_length(i):
Expand Down Expand Up @@ -547,8 +549,7 @@ def _check_packed_address(self, address, expected_len):
msg = (
'%r (len %d != %d) is not permitted as an IPv%d address. '
'Did you pass in a bytes (str in Python 2) instead of'
' a unicode object?'
)
' a unicode object?')
raise AddressValueError(msg % (address, address_len,
expected_len, self._version))

Expand Down Expand Up @@ -1083,8 +1084,7 @@ def supernet(self, prefixlen_diff=1, new_prefix=None):
(self.prefixlen, prefixlen_diff))
return self.__class__((
int(self.network_address) & (int(self.netmask) << prefixlen_diff),
new_prefixlen
))
new_prefixlen))

@property
def is_multicast(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import logging

try:
from oem_format_msgpack.packer import Packer
import msgpack
except ImportError:
Packer = None
msgpack = None

log = logging.getLogger(__name__)
Expand All @@ -23,7 +25,7 @@ def available(self):

def dump_file(self, obj, fp):
try:
msgpack.dump(obj, fp)
fp.write(Packer().pack(obj))
return True
except Exception as ex:
log.warn('Unable to dump object to file: %s', ex, exc_info=True)
Expand All @@ -32,12 +34,11 @@ def dump_file(self, obj, fp):

def dump_string(self, obj):
try:
msgpack.dumps(obj)
return True
return Packer().pack(obj)
except Exception as ex:
log.warn('Unable to dump object: %s', ex, exc_info=True)

return False
return None

def load_file(self, fp):
try:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from msgpack.fallback import DEFAULT_RECURSE_LIMIT
import msgpack.fallback


class Packer(msgpack.fallback.Packer):
def _fb_pack_map_pairs(self, n, pairs, nest_limit=DEFAULT_RECURSE_LIMIT):
return super(Packer, self)._fb_pack_map_pairs(
n, sorted(pairs),
nest_limit=nest_limit
)
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def to_iterable(value):


def synchronized(f_lock, mode='full'):
if inspect.isfunction(f_lock) and f_lock.func_code.co_name != '<lambda>':
if inspect.isfunction(f_lock) and f_lock.__name__ != '<lambda>':
return synchronized(lambda self: self._lock, mode)(f_lock)

if mode == 'full':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import logging
import re
import sys
import time
import websocket

Expand All @@ -25,6 +26,13 @@
}


class ConnectionState(object):
disconnected = 'disconnected'

connecting = 'connecting'
connected = 'connected'


class WebSocket(Source):
name = 'websocket'
events = [
Expand All @@ -48,8 +56,8 @@ class WebSocket(Source):
def __init__(self, activity):
super(WebSocket, self).__init__()

self.state = ConnectionState.disconnected
self.ws = None
self.reconnects = 0

# Pipe events to the main activity instance
self.pipe(self.events, activity)
Expand All @@ -70,33 +78,86 @@ def connect(self):
if params:
uri += '?' + urlencode(params)

# Create websocket connection
self.ws = websocket.create_connection(uri)
# Ensure existing websocket has been closed
if self.ws:
try:
self.ws.close()
except Exception as ex:
log.info('Unable to close existing websocket: %s', ex)

def run(self):
self.connect()
# Update state
self.state = ConnectionState.connecting

log.debug('Ready')
# Try connect to notifications websocket
try:
self.ws = websocket.create_connection(uri)

while True:
# Update state
self.state = ConnectionState.connected
except Exception as ex:
# Reset state
self.ws = None
self.state = ConnectionState.disconnected

raise ex

def connect_retry(self):
if self.state == ConnectionState.connected:
return True

log.debug('Connecting...')

attempts = 0
exc_info = None
ex = None

while self.state == ConnectionState.disconnected and attempts < 10:
try:
self.process(*self.receive())
attempts += 1

# successfully received data, reset reconnects counter
self.reconnects = 0
except websocket.WebSocketConnectionClosedException:
if self.reconnects <= 5:
self.reconnects += 1
# Attempt socket connection
self.connect()

# Increasing sleep interval between reconnections
if self.reconnects > 1:
time.sleep(2 * (self.reconnects - 1))
# Connected
log.debug('Connected')
return True
except websocket.WebSocketBadStatusException as ex:
exc_info = sys.exc_info()

log.info('WebSocket connection has closed, reconnecting...')
self.connect()
else:
log.error('WebSocket connection unavailable, activity monitoring not available')
# Break on client errors (not authorized, etc..)
if 400 <= ex.status_code < 500:
break
except Exception as ex:
exc_info = sys.exc_info()

# Retry socket connection
sleep = int(round(attempts * 1.2, 0))

log.debug('Connection failed: %s (retrying in %d seconds)', ex, sleep)
time.sleep(sleep)

# Check if we are connected
if self.state == ConnectionState.connected:
log.debug('Connected')
return True

# Display connection error
log.error('Unable to connect to the notification channel: %s (after %d attempts)', ex, attempts, exc_info=exc_info)
return False

def run(self):
# Connect to notification channel
if not self.connect_retry():
return

# Receive notifications from channel
while True:
try:
self.process(*self.receive())
except websocket.WebSocketConnectionClosedException:
# Try reconnect to notification channel
if not self.connect_retry():
return

def receive(self):
frame = self.ws.recv_frame()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PLUGIN_IDENTIFIER = 'com.plexapp.plugins.trakttv'
PLUGIN_PREFIX = '/video/trakt'

PLUGIN_VERSION_BASE = (1, 3, 1)
PLUGIN_VERSION_BASE = (1, 3, 2)
PLUGIN_VERSION_BRANCH = 'master'

PLUGIN_VERSION = build_version(PLUGIN_VERSION_BASE, PLUGIN_VERSION_BRANCH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,13 @@ def _label_from_frame(frame):
class ErrorReporter(object):
plugin = ErrorReporterClient(
project=1,
key='64b848c805bb473a8dd94b07565453c9:a1d132a55ec5485385d10ed4bccfa129',
key='40f642fc99094fb9b95cb030ce9e3756:35839621b0f548d2a1f201cf38501570',
**PARAMS
)

trakt = ErrorReporterClient(
project=8,
key='131d79120caa44ffa0ee7422ddd1f57b:54a32412da0842af9191106b017acf79',
key='c5ba8538a4c3488ab22de7934d10437c:514e1660bd504359884bb6b47c9d14f8',
enable_breadcrumbs=False,
**PARAMS
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Mapper(Module):
services = {
'anidb': [
# Prefer movies
'imdb', 'tmdb:movie',
'tmdb:movie', 'imdb',

# Fallback to shows
'tvdb'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
log = logging.getLogger(__name__)

AUDIO_CODECS = {
'lpcm': 'pcm',
'mp3': None,
'aac': None,
'ogg': 'vorbis',
'wma': None,

'dts': '(dca|dta)',
'dts_ma': 'dtsma',

'dolby_prologic': 'dolby.?pro',
'dolby_digital': 'ac.?3',
'dolby_truehd': 'truehd'
'lpcm': 'pcm',
'mp3': None,
'aac': None,
'ogg': 'vorbis',
'wma': None,

'dts': '(dca|dta)',
'dts_ma': 'dtsma',

'dolby_prologic': 'dolby.?pro',
'dolby_digital': 'ac.?3',
'dolby_digital_plus': 'eac.?3',
'dolby_truehd': 'truehd'
}

# compile patterns in `AUDIO_CODECS`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys

# http://www.python.org/dev/peps/pep-0396/
__version__ = '0.1.9'
__version__ = '0.2.2'

if sys.version_info[:2] < (2, 4):
raise RuntimeError('PyASN1 requires Python 2.4 or later')
Expand Down
Loading

0 comments on commit a6ab5f4

Please sign in to comment.