Wrote a quick plugin to check which channels a GUID can access
This commit is contained in:
parent
d0ca476b35
commit
fe190b55d0
55
plugins/guid_channels.py
Normal file
55
plugins/guid_channels.py
Normal file
@ -0,0 +1,55 @@
|
||||
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 [ '-gc','--guid_channels', 'store_true', "Return working channels for GUID" ]
|
||||
|
||||
def startup(self) :
|
||||
|
||||
# Load sub pack from options
|
||||
for requirement in ['sub_pack'] :
|
||||
if requirement not in self.config or (requirement in self.config and self.config[requirement] is ''):
|
||||
self.error.append('Missing required config option ' + requirement)
|
||||
return
|
||||
self.sub_pack = self.config['sub_pack']
|
||||
self.channels = json.loads(requests.get('https://cbd46b77.cdn.cms.movetv.com/cms/publish3/domain/channels/v4/-0700/770/' + self.sub_pack + '/1.json').text)['subscriptionpacks'][0]['channels']
|
||||
self.channels_small = {x['channel_guid']:x['title'] for x in self.channels}
|
||||
self.debug('Beginning search for subscribed channels for GUID.',1)
|
||||
self.debug('This will take a long time. Increase the verbosity level to watch the progress.',1)
|
||||
self.progress = 0
|
||||
self.goal = len(self.channels_small)
|
||||
def perform_lookup(self,subject) :
|
||||
channels = {}
|
||||
guid = list(re.match('([0-9a-fA-F]*)', subject.replace('-','')).groups())
|
||||
if len(guid) > 0 and len(guid[0]) == 32 :
|
||||
guid = guid[0]
|
||||
else :
|
||||
guid = None
|
||||
self.debug('Subject does not appear to be a valid GUID',1)
|
||||
for channel in self.channels_small :
|
||||
self.progress += 1
|
||||
resp = self.make_drm_request(channel,guid)
|
||||
if resp == 200 :
|
||||
channels.update({channel:self.channels_small[channel]})
|
||||
return {'channels':channels,'count':len(channels)}
|
||||
|
||||
def make_drm_request(self,channel_guid,user_guid) :
|
||||
"""Starts a widevine handshake and looks for 200 to indicate the asset/channel is eligible for play."""
|
||||
payload = {
|
||||
'env': 'production',
|
||||
'user_id': user_guid,
|
||||
'channel_id': channel_guid,
|
||||
'message': [8,4]
|
||||
}
|
||||
drm_req = requests.post('http://p-drmwv.movetv.com/widevine/proxy', json=payload)
|
||||
if drm_req.status_code == 200 :
|
||||
verbosity = 2
|
||||
else :
|
||||
verbosity = 3
|
||||
self.debug('Got ' + str(drm_req.status_code) + ' for channel ' + channel_guid + ' for user ' + user_guid + ' (' + str(self.progress) + '/' + str(self.goal) + ')',verbosity)
|
||||
return drm_req.status_code
|
Loading…
Reference in New Issue
Block a user