ifxlookup/plugins/channel.py

33 lines
1.1 KiB
Python

from servicebase import ServiceBase
import re
import requests
import json
class ServiceDelegate(ServiceBase) :
def get_arguments(cls) :
"""Returns an array of information used to construct an argumentparser argument."""
return [ '-ch','--channel', 'store_true', "Return CMS channel info about the subject (channel)" ]
def startup(self) :
pass
def perform_lookup(self,subject) :
channel_guid = list(re.match('([0-9a-fA-F]*)', subject).groups())
if len(channel_guid) > 0 and len(channel_guid[0]) == 32 :
channel_guid = channel_guid[0]
else :
channel_guid = None
self.debug('Channel does not appear to be a channel_id',3)
if channel_guid :
channel_req = requests.get('https://cbd46b77.cdn.cms.movetv.com/cms/api/channels/' + channel_guid + '/schedule/now/playback_info.qvt')
if channel_req.status_code == 200 :
payload = json.loads(channel_req.text)
return_dict = payload['playback_info']
return return_dict
else :
self.debug('Got ' + channel_req.status_code + ' for channel info request from CMS',1)
def search_for_channel(self,subject) :
pass