Esempio n. 1
0
 def test_get_kodi_major_version(self):
     for b in fakes.KODI_BUILDS:
         with mock.patch.object(utils,
                                'get_info_label',
                                return_value=b['build']):
             ver = utils.get_kodi_major_version()
             self.assertEqual(ver, b['major_version'])
 def _is_kodi_supported_version(cls):
     if utils.get_kodi_major_version() < 18:
         utils.dialog(
             'Kodi 18+ Required',
             'The minimum version of Kodi required for DASH/DRM '
             'protected content is v18. Please upgrade in order to '
             'use this feature.')
         return False
     return True
    def check_inputstream(self, drm=True):
        """Check InputStream Adaptive is installed and ready

        Main function call to check all components required are available for
        DRM playback before setting the resolved URL in Kodi.
        drm -- set to false if you just want to check for inputstream.adaptive
        and not widevine components eg. HLS playback
        """
        # DRM not supported
        if drm and not self._is_wv_drm_supported():
            # TODO(andy): Store something in settings to prevent this message
            # appearing more than once?
            utils.dialog(
                'Platform not supported',
                '{0} not supported for DRM playback. '
                'For more information, see our DRM FAQ at {1}'
                ''.format(self.get_platform_name(), config.DRM_INFO))
            return False

        # Kodi version too old
        if drm and utils.get_kodi_major_version() < 18:
            utils.dialog(
                'Kodi version not supported for DRM',
                'This version of Kodi is not currently supported for viewing '
                'DRM encrypted content. Please upgrade to Kodi v18.')
            return False

        addon = self.get_addon()
        if not addon:
            utils.dialog(
                'Missing inputstream.adaptive add-on',
                'inputstream.adaptive VideoPlayer InputStream add-on not '
                'found or not enabled. This add-on is required to view DRM '
                'protected content.')
            return False

        utils.log('Found inputstream.adaptive version is {0}'.format(
            addon.getAddonInfo('version')))

        # widevine built into android - not supported on 17 atm though
        if self._is_android():
            utils.log('Running on Android')
            return True

        # checking for installation of inputstream.adaptive (eg HLS playback)
        if not drm:
            utils.log('DRM checking not requested')
            return True

        # only 32bit userspace supported for linux aarch64 no 64bit wvcdm
        if self._get_platform() == ('Linux', 'aarch64'):
            if self._get_kodi_arch() == '64bit':
                utils.dialog(
                    '64 bit build for aarch64 not supported',
                    'A build of your OS that supports 32 bit userspace '
                    'binaries is required for DRM playback. We recommend '
                    'CoreELEC to support this.')

        cdm_fn = self._get_wvcdm_filename()
        cdm_paths = self._get_wvcdm_paths(addon)
        if not any(os.path.isfile(os.path.join(p, cdm_fn)) for p in cdm_paths):
            if utils.dialog_yn(
                    'Missing Widevine module',
                    '{0} not found in any expected location.'.format(cdm_fn),
                    'Do you want to attempt downloading the missing '
                    'Widevine CDM module to your system for DRM support?'):
                self._get_wvcdm()
            else:
                # TODO(andy): Ask to never attempt again
                return False

        return True