Skip to content

Commit

Permalink
Merge branch 'next-version'
Browse files Browse the repository at this point in the history
  • Loading branch information
pkscout committed Jun 3, 2020
2 parents 355d009 + 0ea74ca commit d2e7e82
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 21 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v.0.3.7
- updated nextpvr api so script can use a custom device name during login
- fix for logger not handling utf-8
- fix for duplicate recurring recordings being scheduled

v.0.3.6
- fix for log files not always ending up in the right place
- updated API libraries
Expand Down
2 changes: 1 addition & 1 deletion logintest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def hashMe (thedata):


def sidLogin5():
method = 'session.initiate&ver=1.0&device=emby'
method = 'session.initiate&ver=1.0&device=testlogin'
ret, keys = doRequest5(method)
global sid
if ret == True:
Expand Down
8 changes: 5 additions & 3 deletions resources/lib/apis/nextpvr.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#v.0.1.4
#v.0.1.6

from . import url

Expand All @@ -8,11 +8,12 @@

class API( object ):

def __init__( self, dvr_host, dvr_port, dvr_auth ):
def __init__( self, dvr_host, dvr_port, dvr_auth, device ):
"""Creates NextPVR API object."""
url_end = 'services/service'
self.BASEURL = 'http://%s:%s/%s' % (dvr_host, dvr_port, url_end)
self.PINCODE = dvr_auth
self.DEVICE = device
self.PARAMS = {}
self.PARAMS['format'] = 'json'
self.PARAMS['sid'] = ''
Expand Down Expand Up @@ -66,6 +67,7 @@ def scheduleNewRecurringRecording( self, name, params=None ):
loglines.append( 'no match between listing %s and name %s' % (listings.get( 'name' ), name) )
return False, loglines, []


def _do_call( self, params ):
loglines = []
if not params['sid']:
Expand All @@ -86,7 +88,7 @@ def _login( self ):
params = { 'format':'json' }
params['method'] = 'session.initiate'
params['ver'] = '1.0'
params['device'] = 'tvmaze.integration'
params['device'] = self.DEVICE
success, loglines, keys = JSONURL.Get( self.BASEURL, params=params )
if success:
sid = keys['sid']
Expand Down
31 changes: 25 additions & 6 deletions resources/lib/apis/tvmaze.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#v.0.3.4
#v.0.5.2

import json
from . import url
Expand All @@ -13,7 +13,7 @@
class API( object ):

def __init__( self, user='', apikey='' ):
"""create a TV Maze API object"""
"""Create a TV Maze API object."""
self.PUBLICURL = 'https://api.tvmaze.com'
self.USER = user
self.APIKEY = apikey
Expand Down Expand Up @@ -43,17 +43,36 @@ def getTaggedShows( self, tag, params=None ):
return self._call( 'tags/%s/shows' % tag, params, auth=True )


def getTags( self, params=None ):
return self._call( 'tags', params, auth=True )


def findSingleShow( self, showname ):
params = {'q':showname}
return self._call( '/singlesearch/shows', params )


def followShow( self, showid, params=None ):
return self._call( 'follows/shows/%s' % showid, params, thetype='put', auth=True )


def markEpisode( self, episodeid, marked_as=0, marked_at=0, params=None ):
if marked_as == -1:
return self._call( 'episodes/%s' % episodeid, params, thetype='delete', auth=True )
payload = {'episode_id':0, 'type':marked_as, 'marked_at':marked_at }
return self._call( 'episodes/%s' % episodeid, params, data=json.dumps( payload ), thetype='put', auth=True )


def unTagShow( self, show, tag, params=None ):
return self._call( 'tags/%s/shows/%s' % (tag, show), params, auth=True, thetype='delete' )
def tagShow( self, showid, tagid, params=None ):
return self._call( 'tags/%s/shows/%s' % (tagid, showid), params, auth=True, thetype='put' )


def getTags( self, params=None ):
return self._call( 'tags', params, auth=True )
def unTagShow( self, showid, tagid, params=None ):
return self._call( 'tags/%s/shows/%s' % (tagid, showid), params, auth=True, thetype='delete' )


def unFollowShow( self, showid, params=None ):
return self._call( 'follows/shows/%s' % showid, params, thetype='delete', auth=True )


def _call( self, url_end, params, data=None, auth=False, thetype="get" ):
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/apis/url.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#v.0.5.3
#v.0.5.4

import socket
import requests as _requests
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/dvrs/nextpvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DVR:

def __init__( self, config ):
"""Creates a NextPVR DVR object."""
self.APICALL = nextpvr.API( config.Get( 'dvr_host' ), config.Get( 'dvr_port' ), config.Get( 'dvr_auth' ) )
self.APICALL = nextpvr.API( config.Get( 'dvr_host' ), config.Get( 'dvr_port' ), config.Get( 'dvr_auth' ), 'tvmaze.integration' )


def scheduleNewRecurringRecording( self, name, params ):
Expand Down
6 changes: 3 additions & 3 deletions resources/lib/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _check_recurring( self, show ):
self.LW.log( ['no recurring recordings found, trying to schedule recording'], 'info' )
return False
self.LW.log( ['found some recurring recordings, checking to see if one matches %s' % show['name']], 'info' )
if show in recurrings:
if show['name'] in recurrings:
self.LW.log( ['found a matching recurring recording, skipping'], 'info' )
return True
self.LW.log( ['no matching recurring recording, trying to schedule recording'], 'info' )
Expand Down Expand Up @@ -125,7 +125,7 @@ def _mark_aquired( self ):
followed_name = followed_show['_embedded']['show']['name']
except KeyError:
continue
self.LW.log( ['checking for %s matching %s' % (show_info['name'], followed_show['_embedded']['show']['name'])], 'info' )
self.LW.log( ['checking for %s matching %s' % (show_info['name'], followed_name)], 'info' )
if followed_name == show_info['name']:
self.LW.log( ['found match for %s' % show_info['name'] ], 'info' )
tvmazeid = followed_show['show_id']
Expand Down Expand Up @@ -212,7 +212,7 @@ def _get_followed( self ):
items.append( show['_embedded']['show'] )
except KeyError:
continue
self.LW.log( ['continuing with updated list of shows of:', items], 'info' )
self.LW.log( ['continuing with updated list of shows of:', items] )
return items


Expand Down
12 changes: 6 additions & 6 deletions resources/lib/xlogger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#v.0.4.8
#v.0.4.12

try:
from kodi_six import xbmc
Expand All @@ -22,9 +22,9 @@ def __init__( self, logconfig="timed", logformat='%(asctime)-15s %(levelname)-8s
self.logger = logging.getLogger( logname )
self.logger.setLevel( logging.DEBUG )
if logconfig == 'timed':
lr = logging.handlers.TimedRotatingFileHandler( logfile, when=when, backupCount=numbackups)
lr = logging.handlers.TimedRotatingFileHandler( logfile, when=when, backupCount=numbackups, encoding='utf-8')
else:
lr = logging.handlers.RotatingFileHandler( logfile, maxBytes=maxsize, backupCount=numbackups )
lr = logging.handlers.RotatingFileHandler( logfile, maxBytes=maxsize, backupCount=numbackups, encoding='utf-8' )
lr.setLevel( logging.DEBUG )
lr.setFormatter( logging.Formatter( logformat ) )
self.logger.addHandler( lr )
Expand All @@ -46,7 +46,7 @@ def log( self, loglines, loglevel='' ):
loglevel = self.logger.debug
for line in loglines:
try:
if type(line).__name__=='unicode':
if type(line).__name__ == 'unicode':
line = line.encode('utf-8')
str_line = line.__str__()
except Exception as e:
Expand All @@ -67,7 +67,7 @@ def _output( self, line, loglevel ):
def _output_file( self, line, loglevel ):
if self.LOGDEBUG or loglevel != self.logger.debug:
try:
loglevel( '%s %s' % (self.LOGPREAMBLE, line.__str__()) )
loglevel( '%s %s' % (self.LOGPREAMBLE, line ) )
except Exception as e:
self.logger.debug( '%s unable to output logline' % self.LOGPREAMBLE )
self.logger.debug( '%s %s' % (self.LOGPREAMBLE, e.__str__()) )
Expand All @@ -79,4 +79,4 @@ def _output_xbmc( self, line, loglevel ):
xbmc.log( '%s %s' % (self.LOGPREAMBLE, line.__str__()), loglevel)
except Exception as e:
xbmc.log( '%s unable to output logline' % self.LOGPREAMBLE, loglevel)
xbmc.log ('%s %s' % (self.LOGPREAMBLE, e.__str__()), loglevel)
xbmc.log ('%s %s' % (self.LOGPREAMBLE, e.__str__()), loglevel)

0 comments on commit d2e7e82

Please sign in to comment.