# Path: resources/lib/modules/hlshelper.py
# def get_max_bandwidth():
# def pick_bandwidth(url):


import requests
import sys
import threading
import resources.lib.modules.control as control
import xbmc
from urlparse import urlparse
from auth import gettoken
from auth import get_default_profile
from private_data import get_device_id
from resources.lib.modules import hlshelper
        control.log("Oi Play - play_stream: id=%s | meta=%s" % (id, meta))

        if id is None: return

        provider = meta.get('provider')
        self.isLive = meta.get('livefeed', False)

        data = self.individualize(self.isLive, id, provider)

        if not data or 'individualization' not in data:
            error_message = '%s: %s' % (data.get('reason'), data.get('detail')) if data and data.get('reason') else control.lang(34100).encode('utf-8')
            control.infoDialog(error_message, icon='ERROR')
            return

        encrypted = 'drm' in data and 'licenseUrl' in data['drm']

        if encrypted and not control.is_inputstream_available():
            control.okDialog(u'Oi Play', control.lang(34103).encode('utf-8'))
            return

        url = data['individualization']['url']

        # info = data.get('token', {}).get('cmsChannelItem') or data.get('token', {}).get('cmsContentItem')

        control.log("live media url: %s" % url)

        self.offset = float(meta['milliseconds_watched']) / 1000.0 if 'milliseconds_watched' in meta else 0

        parsed_url = urlparse(url)
        if ".m3u8" in parsed_url.path:

# Path: resources/lib/modules/hlshelper.py
# def get_max_bandwidth():
# def pick_bandwidth(url):


# Path: resources/lib/modules/oiplay/player.py
import requests
import sys
import threading
import resources.lib.modules.control as control
import xbmc
from urlparse import urlparse
from auth import gettoken
from auth import get_default_profile
from private_data import get_device_id
from resources.lib.modules import hlshelper

        control.log("Oi Play - play_stream: id=%s | meta=%s" % (id, meta))

        if id is None: return

        provider = meta.get('provider')
        self.isLive = meta.get('livefeed', False)

        data = self.individualize(self.isLive, id, provider)

        if not data or 'individualization' not in data:
            error_message = '%s: %s' % (data.get('reason'), data.get('detail')) if data and data.get('reason') else control.lang(34100).encode('utf-8')
            control.infoDialog(error_message, icon='ERROR')
            return

        encrypted = 'drm' in data and 'licenseUrl' in data['drm']

        if encrypted and not control.is_inputstream_available():
            control.okDialog(u'Oi Play', control.lang(34103).encode('utf-8'))
            return

        url = data['individualization']['url']

        # info = data.get('token', {}).get('cmsChannelItem') or data.get('token', {}).get('cmsContentItem')

        control.log("live media url: %s" % url)

        self.offset = float(meta['milliseconds_watched']) / 1000.0 if 'milliseconds_watched' in meta else 0

        parsed_url = urlparse(url)
        if ".m3u8" in parsed_url.path:

            self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth(url)