예제 #1
0
파일: addon.py 프로젝트: Luky68/archivczsk
    def __init__(self, info, repository):
        self.repository = repository
        self.info = info

        self.id = info.id
        self.name = info.name
        self.version = info.version
        self.author = info.author
        self.description = info.description
        self.changelog = info.changelog
        self.path = info.path
        self.relative_path = os.path.relpath(self.path, repository.path)

        log.info("initializing %s", self)

        self._updater = repository._updater
        self.__need_update = False

        # load languages
        self.language = AddonLanguage(self, os.path.join(self.path, self.repository.addon_languages_relpath))
        if self.language.has_language(settings.LANGUAGE_SETTINGS_ID):
            self.language.set_language(settings.LANGUAGE_SETTINGS_ID)
        else:
            #fix to use czech language instead of slovak language when slovak is not available
            if settings.LANGUAGE_SETTINGS_ID == 'sk' and self.language.has_language('cs'):
                self.language.set_language('cs')
            else:
                self.language.set_language('en')

        # load settings
        self.settings = AddonSettings(self, os.path.join(self.path, self.repository.addon_settings_relpath))

        # loader to handle addon imports
        self.loader = AddonLoader(self)
예제 #2
0
 def start(self):
     if not os.path.exists(self.destDir):
         os.makedirs(self.destDir)
     self._startCB()
     cmd = toString(self._buildCmd())
     log.info("Download.start \"%s\"" % cmd)
     self.pp.execute(cmd)
예제 #3
0
 def load_skin():
     try:
         from enigma import getDesktop
         desktop_width = getDesktop(0).size().width()
         log.logDebug("Screen width %s px"%desktop_width)
         if  desktop_width >= 1280:
             if DMM_IMAGE:
                 if desktop_width == 1920:
                     skin_default_path = os.path.join(settings.SKIN_PATH, "default_dmm_fhd.xml")
                 elif desktop_width == 3840:
                     skin_default_path = os.path.join(settings.SKIN_PATH, "default_dmm_uhd.xml")
                 else:
                     skin_default_path = os.path.join(settings.SKIN_PATH, "default_dmm_hd.xml")
             else:
                 if desktop_width == 1920:
                     skin_default_path = os.path.join(settings.SKIN_PATH, "default_fhd.xml")
                 elif desktop_width == 3840:
                     skin_default_path = os.path.join(settings.SKIN_PATH, "default_uhd.xml")
                 else:
                     skin_default_path = os.path.join(settings.SKIN_PATH, "default_hd.xml")
         else:
             skin_default_path = os.path.join(settings.SKIN_PATH, "default_sd.xml")
         skin_name = config.plugins.archivCZSK.skin.value
         skin_path = os.path.join(settings.SKIN_PATH, skin_name + ".xml")
         if skin_name == 'auto' or not os.path.isfile(skin_path):
             skin_path = skin_default_path
         log.info("loading skin %s" % skin_path)
         log.logDebug("loading skin %s" % skin_path)
         loadSkin(skin_path)
     except:
         log.logError("Load plugin skin failed.\n%s"%traceback.format_exc())
         pass
예제 #4
0
    def get_content(self, session, params, successCB, errorCB):
        log.info('%s get_content - params: %s' % (self, str(params)))
        # add/remove trakt compatibility on every content request
        if self.video_addon.setting_exist('trakt_enabled'):
            if self.video_addon.get_setting('trakt_enabled'):
                if 'trakt' not in self.capabilities:
                    self.capabilities.append('trakt')
            else:
                if 'trakt' in self.capabilities:
                    self.capabilities.remove('trakt')

        self.__clear_list()
        self.content_deferred = defer.Deferred()
        self.content_deferred.addCallback(self._resolve_video_items)
        self.content_deferred.addCallbacks(successCB, errorCB)
        # setting timeout for resolving content
        loading_timeout = int(self.video_addon.get_setting('loading_timeout'))
        if loading_timeout > 0:
            socket.setdefaulttimeout(loading_timeout)

        try:
            ssl._create_default_https_context = ssl._create_unverified_context
        except:
            pass
        thread_task = task.Task(self._get_content_cb, self.run_script, session, params)
        thread_task.run()
        return self.content_deferred
예제 #5
0
 def _get_handler(self, item):
     for handler in self._handlers:
         if handler.can_handle(item):
             log.info("found handler %s" % (handler))
             return handler
         else:
             log.info("%s cannot handle %s" % (handler, item))
예제 #6
0
파일: client.py 프로젝트: m1ngr/archivczsk
def add_video(name, url, subs=None, image=None, infoLabels={}, menuItems={}, filename=None, live=False, stream=None, settings=None):

    """
    adds video item to content screen
        @param url: play url
        @param subs: subtitles url
        @param image: image of video item
        @param infoLabels: dictationary of informations{'title':title,'plot':plot,'rating':rating,''}"
        @param filename: set this filename when downloading
        @param live: is video live stream
        @param settings: dictationary of player/download settings{"user-agent",:"","extra-headers":{}}
    """

    video_it = create_video_it(name=name,
                               url=url,
                               subs=subs,
                               image=image,
                               infoLabels=infoLabels,
                               menuItems=menuItems,
                               filename=filename,
                               live=live,
                               stream=stream,
                               settings=settings)

    if not isinstance(url, basestring):
        log.info('add_video - ignoring %s, invalid url', repr(video_it))
    else:
        GItem_lst[0].append(video_it)
예제 #7
0
 def all_done(result_list):
     for __, (data, item) in result_list:
         tmp_list = []
         for stream_dict in get_streams_from_manifest(item.url, data):
             video_item = PVideoResolved()
             video_item.subs = item.subs
             video_item.settings = item.settings.copy()
             video_item.url = stream_dict['url']
             video_item.quality = "%s b/s"%stream_dict['bandwidth']
             video_item.bandwidth = int(stream_dict['bandwidth'])
             if 'resolution' in stream_dict:
                 video_item.quality = stream_dict['resolution'].split('x')[1] + "p"
             # TODO remove workaround of embedding
             # quality in title in addons
             video_item.name = name = item.name
             quality = video_item.quality
             if quality and quality not in name:
                 if "[???]" in name:
                     video_item.name = name.replace("[???]","[%s]"%(quality))
                 else:
                     video_item.name = "[%s] %s"%(i.quality, i.name)
             tmp_list.append(video_item)
         tmp_list.sort(key=operator.attrgetter('bandwidth'), reverse=True)
         if tmp_list:
             log.info("%s __resolve_video_items: found %d streams"%(self, len(tmp_list)))
             item_list.remove(item)
             item_list.extend(tmp_list)
     return result
예제 #8
0
파일: addon.py 프로젝트: Luky68/archivczsk
    def __init__(self, info, repository):
        Addon.__init__(self, info, repository)
        self.library = self.info.library
        log.info('%s successfully loaded', self)

        lib_path = os.path.join(self.path, self.library)
        self.loader.add_path(lib_path)
예제 #9
0
파일: addon.py 프로젝트: Luky68/archivczsk
    def __init__(self, info_file):
        log.info("initializing info of addon from %s" , info_file)

        pars = parser.XBMCAddonXMLParser(info_file)
        addon_dict = pars.parse()


        self.id = addon_dict['id']
        self.name = addon_dict['name']
        self.version = addon_dict['version']
        self.author = addon_dict['author']
        self.type = addon_dict['type']
        self.broken = addon_dict['broken']
        self.path = os.path.dirname(info_file)
        self.library = addon_dict['library']
        self.script = addon_dict['script']
        self.tmp_path = settings.TMP_PATH
        self.data_path = os.path.join(config.plugins.archivCZSK.dataPath.getValue(), self.id)
        self.profile = self.data_path

        # create data_path(profile folder)
        util.make_path(self.data_path)

        if settings.LANGUAGE_SETTINGS_ID in addon_dict['description']:
            self.description = addon_dict['description'][settings.LANGUAGE_SETTINGS_ID]
        elif settings.LANGUAGE_SETTINGS_ID == 'sk' and 'cs' in addon_dict['description']:
            self.description = addon_dict['description']['cs']
        else:
            if not 'en' in addon_dict['description']:
                self.description = u''
            else:
                self.description = addon_dict['description']['en']

        self.requires = addon_dict['requires']
        self.image = os.path.join(self.path, 'icon.png')

        #changelog
        changelog_path = None
        if os.path.isfile(os.path.join(self.path, 'changelog.txt')):
            changelog_path = os.path.join(self.path, 'changelog.txt')

        elif os.path.isfile(os.path.join(self.path, 'Changelog.txt')):
            changelog_path = os.path.join(self.path, 'Changelog.txt')

        else:
            changelog_path = None

        if changelog_path is not None:
            with open(changelog_path, 'r') as f:
                text = f.read()
            try:
                self.changelog = text.decode('windows-1250')
            except Exception:
                log.debug('cannot decode c[C]angleog.txt')
                self.changelog = u''
                pass
        else:
            log.debug('c[C]hangelog.txt missing')
            self.changelog = u''
예제 #10
0
	def playFromPlaylist(self, idx):
		if isinstance(self.it, PPlaylist):
			try:
				self.setPlayItem(self.it.playlist[idx])
			except IndexError:
				log.info('[PlaylistController] index %d doesn\'t exist playlist', idx)
			else:
				self.play()
예제 #11
0
파일: addon.py 프로젝트: mx3L/archivczsk
    def __init__(self, info_file):
        log.info("AddonInfo(%s) initializing.." , '/'.join(info_file.split('/')[-3:]))

        pars = parser.XBMCAddonXMLParser(info_file)
        addon_dict = pars.parse()
        
        self.id = addon_dict['id']
        self.name = addon_dict['name']
        self.version = addon_dict['version']
        self.author = addon_dict['author']
        self.type = addon_dict['type']
        self.broken = addon_dict['broken']
        self.path = os.path.dirname(info_file)
        self.library = addon_dict['library']
        self.script = addon_dict['script']
        self.tmp_path = config.plugins.archivCZSK.tmpPath.value
        self.data_path = os.path.join(config.plugins.archivCZSK.dataPath.getValue(), self.id)
        self.profile = self.data_path

        # create data_path(profile folder)
        util.make_path(self.data_path)

        if settings.LANGUAGE_SETTINGS_ID in addon_dict['description']:
            self.description = addon_dict['description'][settings.LANGUAGE_SETTINGS_ID]
        elif settings.LANGUAGE_SETTINGS_ID == 'sk' and 'cs' in addon_dict['description']:
            self.description = addon_dict['description']['cs']
        else:
            if not 'en' in addon_dict['description']:
                self.description = u''
            else:
                self.description = addon_dict['description']['en']

        self.requires = addon_dict['requires']
        self.image = os.path.join(self.path, 'icon.png')

        #changelog
        changelog_path = None
        if os.path.isfile(os.path.join(self.path, 'changelog.txt')):
            changelog_path = os.path.join(self.path, 'changelog.txt')

        elif os.path.isfile(os.path.join(self.path, 'Changelog.txt')):
            changelog_path = os.path.join(self.path, 'Changelog.txt')

        else:
            changelog_path = None

        if changelog_path is not None:
            with open(changelog_path, 'r') as f:
                text = f.read()
            try:
                self.changelog = text
            except Exception:
                log.error('%s c[C]angleog.txt cannot be decoded', self)
                self.changelog = u''
                pass
        else:
            log.error('%s c[C]hangelog.txt file is missing', self)
            self.changelog = u''
예제 #12
0
 def stop(self):
     if not self.__started:
         log.info("[%s] cannot stop, provider is already stopped",self)
         return
     self.__started = False
     self.__paused = False
     for f in self.on_stop:
         f()
     log.info("[%s] stopped", self)
예제 #13
0
파일: addon.py 프로젝트: mx3L/archivczsk
 def set_language(self, language_id):
     if self.has_language(language_id):
         if self.languages[language_id] is None:
             self.load_language(language_id)
         log.info("%s setting current language %s to %s", self, self.current_language_id, language_id)
         self.current_language_id = language_id
         self.current_language = self.languages[language_id]
     else:
         log.error("%s cannot set language %s, language is not available", self, language_id)
예제 #14
0
 def start(self):
     if self.__started:
         log.info("[%s] cannot start, provider is already started",self)
         return
     self.__started = True
     self.__paused = False
     for f in self.on_start:
         f()
     log.info("[%s] started", self)
예제 #15
0
 def _finishCB(self, retval):
     log.info("Download._finishCB(%d)"%(retval))
     self.running = False
     self.finish_time = time.time()
     if retval == 0 and not self.killed:
         self.downloaded = True
     else:
         self.downloaded = False
     if self.finishCB is not None:
         self.finishCB(self)
예제 #16
0
 def get_content(self, params=None):
     log.info('%s get_content - params: %s' % (self, str(params)))
     if not params or 'categories' in params:
         return self._get_categories()
     if 'category' in params:
         return self._get_category(params['category'])
     if 'category_addons' in params:
         if 'filter_enabled' in params:
             return self._get_category_addons(params['category_addons'], params['filter_enabled'])
         return self._get_category_addons(params['category_addons'])
     if 'categories_user' in params:
         return self._get_categories(user_only=True)
예제 #17
0
 def addDownload(self, download, overrideCB=None):
     log.info("DownloadManager.addDownload(%s,%s)"%(download, str(overrideCB)))
     #check if we didn't download from this url already
     c1 = download.url in [d.url for d in self.download_lst]
     # check if filename already exists
     c2 = os.path.isfile(download.local)
     if not c1 and not c2:
         self.download_lst.append(download)
         download.start()
     else:
         if overrideCB is not None:
             overrideCB(download)
예제 #18
0
 def __showPlaylistCb(self, selection=None):
     log.info('[InfoBarPlaylist] %s %s', str(selection), str(self.__selected))
     if selection is not None and self.__selected != selection:
         self.__selected = selection
         self.__selection = self.__selected
         log.debug('[InfoBarPlaylist] __showPlaylistCb - [%s/%s] %s',
                    self.__selected,
                    self.__last,
                    self.__playlist[self.__selected])
         self.__play()
     else:
         log.debug('[InfoBarPlaylist] __showPlaylistCb - same service')
예제 #19
0
    def createDownload(self, name, url, destination, filename=None, live=False, startCB=None, finishCB=None, stream=None, quiet=False, playDownload=False, headers=None, mode=""):
        log.info("Downloader.createDownload(url=%s,mode=%s"%(toString(url), mode))
        #log.logDebug("Creating download\name=%s\nurl=%s\ndestination=%s\nfilename=%s\nheaders=%s\nmode=%s" % (name, url, destination, filename, headers, mode))
        d = None
        if headers is None:
            headers = {}
        try:
            headers = headers.copy()
        except:
            log.logError("Copy headers for download failed, continute download.\n%s"%traceback.format_exc())
            headers = {}
            pass
        from Plugins.Extensions.archivCZSK.settings import USER_AGENT
        headers.setdefault('User-Agent', USER_AGENT)
        filename, length = getFilenameAndLength(url, headers, filename)
        log.info("Downloader.createDownload() filename=%s, length=%s", toString(filename), length)
        if (((url[0:4] == 'rtmp' and mode in ('auto', 'gstreamer')) or
              (url[0:4] == 'http' and mode  in ('auto', 'gstreamer') and isHLSUrl(url)) or
              (url[0:4] == 'http' and mode in ('auto', 'gstreamer') and playDownload) or
              (url[0:4] == 'http' and mode in ('gstreamer',))) and GST_LAUNCH is not None):
            d = GstDownload(url = url, name = name, destDir = destination, filename=filename, headers=headers)
        elif url[0:4]  == 'rtmp' and mode in ('auto', 'rtmpdump'):
            urlList = url.split()
            rtmp_url = []
            for url in urlList[1:]:
                rtmp = url.split('=', 1)
                rtmp_url.append(' --' + rtmp[0])
                rtmp_url.append("'%s'" % rtmp[1])
            url = "'%s'" % urlList[0] + ' '.join(rtmp_url)
            if not live:
                realtime = True
            else:
                realtime = False
            d = RTMPDownloadE2(url=url, name=name, destDir=destination, 
                    filename=filename, live=live, quiet=quiet, realtime=realtime)
        elif url[0:4] == 'http':
            if isHLSUrl(url):
                raise NotSupportedProtocolError('HLS')
            d = HTTPDownloadE2(name=name, url=url, filename=filename, 
                    destDir=destination, quiet=quiet, headers=headers)
        else:
            protocol = url.split('://')[0].upper()
            log.error('Downloader.createDownload() - not supported protocol %s' % toString(protocol))
            raise NotSupportedProtocolError(protocol)

        if startCB is not None:
            d.onStartCB.append(startCB)
        if finishCB is not None:
            d.onFinishCB.append(finishCB)
        d.status = DownloadStatus(d)
        d.length = length or 0
        return d
예제 #20
0
    def __init__(self, session, download=None, video_check_interval=5, buffer_time=10, seekable=True, pausable=True, autoplay=True):
        self.video_player = None
        self.video = None
        self.session = session
        self.download = download

        self.seekable = seekable
        self.pausable = pausable
        self.autoplay = autoplay

        # buffering flag
        self._buffered = True

        #flag for manual pause of video
        self._user_pause = False

        # checking interval of video when downloading and playing
        self.video_check_interval = video_check_interval * 1000

        # check every second when in buffering state
        self.buffer_check_interval = 1 * 1000

        # to update download status
        self.download_interval_check = self.video_check_interval

        # to make sure that we dont come to end of file when downloading(deadlock) we set time_limit
        self.time_limit = 5 * 90000 #5 seconds

        # set buffer time, its counting after time_limit
        # so realistically we have buffer of size: buffer_time + time_limit
        self.buffer_time = buffer_time * 90000

        # I did couple of tests and seeking is not really precise,
        # so to make sure that we can seek when download we have seek_limit
        self.seek_limit = 140 * 90000

        # timers for checking and buffering
        self.check_timer = None
        self.check_timer_running = False
        self.buffering_timer = None
        self.buffering_timer_running = False

        self.buffered_percent = 0
        self.buffered_time = 0

        self.download_position = 0
        self.player_position = 0
        self.video_length = None
        self.video_length_total = None

        log.info('initializing %s', self)
예제 #21
0
 def open_item(self, item, *args, **kwargs):
     if self.is_exit(item):
         self.exit_item()
     elif self.is_root(item):
         self.root_item(item)
     else:
         handler = self._get_handler(item)
         if handler is not None:
             handler.open_item(item, *args, **kwargs)
         else:
             log.info("cannot open item %s, cannot found its handler" % item)
             self.content_screen.stopLoading()
             self.content_screen.showList()
             self.content_screen.workingFinished()
예제 #22
0
파일: player.py 프로젝트: mx3L/archivczsk
 def player_exit_callback(self, playpos=None):
     log.info("player_exit_callback(%s)", playpos)
     self.video_player = None
     if self.playlist_dialog and self.playlist_dialog.__dict__:
         self.playlist_dialog.close()
         self.playlist_dialog = None
     self._play_item = None
     self.playlist = []
     self.curr_idx = 0
     self.session.nav.playService(self.old_service)
     self.old_service = None
     if self.callback is not None:
         self.callback()
         self.callback = None
예제 #23
0
파일: player.py 프로젝트: mx3L/archivczsk
 def player_callback(self, callback):
     log.info("player_callback(%r)" % (callback,))
     if callback is not None:
         if callback[0] == "eof":
             if callback[1]:
                 self.player_callback(("playlist", "next"))
             else:
                 self.video_player.close()
         elif callback[0] == "exit":
             exit_player = True
             if len(callback) == 2:
                 exit_player = callback[1]
             else:
                 if self.settings.confirmExit.value:
                     self.session.openWithCallback(
                             lambda x:self.player_callback(("exit", x)),
                             MessageBox, text=_("Stop playing this movie?"), 
                             type=MessageBox.TYPE_YESNO)
                     exit_player = False
             if exit_player:
                 playpos = getPlayPositionInSeconds(self.session)
                 duration = getDurationInSeconds(self.session)
                 self.video_player.close()
         elif callback[0] == "playlist":
             if callback[1] == "show":
                 if self.playlist_item is not None:
                     title = self.playlist_item.name
                 else:
                     title = self._play_item.name
                 self.playlist_dialog = self.session.openWithCallback(
                         lambda x: self.player_callback(("playlist", "idx", x)),
                         ArchivCZSKPlaylist, self.playlist, title, self.curr_idx)
             elif callback[1] == "prev":
                 idx = self.curr_idx
                 if idx == 0:
                     idx = len(self.playlist) - 1
                 else:
                     idx -= 1
                 self.play_item(idx = idx)
             elif callback[1] == "next":
                 idx = self.curr_idx
                 # maybe ignore/make optional
                 if idx == len(self.playlist) -1:
                     self.video_player.close()
                 else:
                     idx += 1
                     self.play_item(idx = idx)
             elif callback[1] == "idx":
                 self.play_item(idx = callback[2])
예제 #24
0
 def _finishCB(self, retval):
     log.info("Download._finishCB(%d)"%(retval))
     self.running = False
     self.finish_time = time.time()
     if retval == 1 and not self.killed:
         if os.path.getsize(self.local) > (0.95 * self.length):
             self.downloaded = True
         else:
             self.downloaded = False
     elif retval == 0 and not self.killed:
         self.downloaded = True
     else:
         self.downloaded = False
     if self.finishCB is not None:
         self.finishCB(self)
예제 #25
0
	def playDownload(self, download):
		"""starts playing already downloading item"""
		from Plugins.Extensions.archivCZSK.engine.downloader import Download

		if download and isinstance(download, Download):
			self.download = download
			download_it = PVideo()
			download_it.name = download.name
			download_it.url = download.local
			subs = os.path.splitext(self.download.local)[0] + '.srt'
			subs = os.path.isfile(subs) and subs or None
			self.setMediaItem(download_it)
			self._playStream(download.name, download.local, subs, True)
		else:
			log.info("Provided download instance is None or not instance of Download")
예제 #26
0
	def play(self):
		"""starts playing media stream"""
		if self.play_it:
			srefName = self.play_it.name
			playUrl = self._getPlayUrl(self.play_it)
			self.stopRTMPGWProcess()
			if playUrl.startswith('rtmp') and self.useRtmpgw:
				self.startRTMPGWProcess(self.play_it)
				playUrl = self._getRTMPGWPlayUrl()
				self.seekable = False
				self.pausable = False
			subtitlesUrl = self.play_it.subs
			verifyLink = self.verifyLink
			self._playStream(srefName, playUrl, subtitlesUrl, verifyLink=verifyLink)
		else:
			log.info("Nothing to play. You need to set VideoItem first.")
예제 #27
0
 def do_rtmp_seek(self, seek_time):
     log.info('RTMPSeek to %ss', seek_time)
     self.session.nav.stopService()
     seeking_ref = self.sref_url.find(' start=')
     if seeking_ref != -1:
         sref_url = self.sref_url[:seeking_ref] + ' start=%s' % str(seek_time)
     else:
         sref_url = self.sref_url + ' start=%s' % str(seek_time)
     seek_sref = eServiceReference(self.sref_id, 0, sref_url)
     seek_sref.setName(self.sref_name)
     if self._offset_mode:
         self._base_pts = self._seek_pts
         ServicePositionAdj.setBasePts(self._base_pts)
         if not self._eplayer_gst10_mode:
             ServicePositionAdj.setBaseLength(self._base_pts)
     self.session.nav.playService(seek_sref)
예제 #28
0
파일: addon.py 프로젝트: Luky68/archivczsk
    def __init__(self, info, repository):
        Addon.__init__(self, info, repository)
        self.script = info.script
        self.requires = [require for require in info.requires if require['addon'] not in VideoAddon.ignore_requires]
        if self.script == '':
            raise Exception("%s entry point missing in addon.xml" % self)
        # content provider
        self.downloads_path = self.get_setting('download_path')
        self.shortcuts_path = os.path.join(config.plugins.archivCZSK.dataPath.getValue(), self.id)
        self.provider = VideoAddonContentProvider(self, self.downloads_path, self.shortcuts_path)

        main = self.settings.main
        main.seekable = ConfigYesNo(default=True)
        main.pausable = ConfigYesNo(default=True)

        log.info('%s successfully loaded', self)
예제 #29
0
 def play(self, session, item, mode, cb=None):
     if not self.player:
         use_video_controller = self.player_cfg.useVideoController.value
         self.player = self.player_cls(session, cb, use_video_controller)
     seekable = self.is_seekable()
     pausable = self.is_pausable()
     self.player.setMediaItem(item, seekable=seekable, pausable=pausable)
     self.player.setContentProvider(self)
     if mode in self.capabilities:
         if mode == 'play':
             self.player.play()
         elif mode == 'play_and_download':
             self.player.playAndDownload()
         elif mode == 'play_and_download_gst':
             self.player.playAndDownload(True)
     else:
         log.info('Invalid playing mode - %s', str(mode))
예제 #30
0
파일: player.py 프로젝트: mx3L/archivczsk
 def setAspect(self, aspect, policy, policy2):
     log.info('aspect: %s policy: %s policy2: %s' % (str(aspect), str(policy), str(policy2)))
     log.logDebug('aspect: %s policy: %s policy2: %s' % (str(aspect), str(policy), str(policy2)))
     if aspect:
         try:
             open("/proc/stb/video/aspect", "w").write(aspect)
         except IOError as e:
             print e
     if policy:
         try:
             open("/proc/stb/video/policy", "w").write(policy)
         except IOError as e:
             print e
     if policy2:
         try:
             open("/proc/stb/video/policy2", "w").write(policy2)
         except IOError as e:
             print e
예제 #31
0
 def setAspect(self, aspect, policy, policy2):
     log.info('aspect: %s policy: %s policy2: %s' %
              (str(aspect), str(policy), str(policy2)))
     log.logDebug('aspect: %s policy: %s policy2: %s' %
                  (str(aspect), str(policy), str(policy2)))
     if aspect:
         try:
             open("/proc/stb/video/aspect", "w").write(aspect)
         except IOError as e:
             print e
     if policy:
         try:
             open("/proc/stb/video/policy", "w").write(policy)
         except IOError as e:
             print e
     if policy2:
         try:
             open("/proc/stb/video/policy2", "w").write(policy2)
         except IOError as e:
             print e
예제 #32
0
    def get_content(self, session, params, successCB, errorCB):
        log.info('%s get_content - params: %s' % (self, str(params)))
        log.logDebug("Video addon content provider '%s' start..." % self)
        self.__clear_list()
        self.content_deferred = defer.Deferred()
        self.content_deferred.addCallback(self._resolve_video_items)
        self.content_deferred.addCallbacks(successCB, errorCB)
        # setting timeout for resolving content
        loading_timeout = int(self.video_addon.get_setting('loading_timeout'))
        if loading_timeout > 0:
            socket.setdefaulttimeout(loading_timeout)

        try:
            ssl._create_default_https_context = ssl._create_unverified_context
        except:
            pass
        thread_task = task.Task(self._get_content_cb, self.run_script, session,
                                params)
        thread_task.run()
        return self.content_deferred
예제 #33
0
    def __init__(self, info, repository):
        Addon.__init__(self, info, repository)
        self.script = info.script
        self.requires = [
            require for require in info.requires
            if require['addon'] not in VideoAddon.ignore_requires
        ]
        if self.script == '':
            raise Exception("%s entry point missing in addon.xml" % self)
        # content provider
        self.downloads_path = self.get_setting('download_path')
        self.shortcuts_path = os.path.join(
            config.plugins.archivCZSK.dataPath.getValue(), self.id)
        self.provider = VideoAddonContentProvider(self, self.downloads_path,
                                                  self.shortcuts_path)

        main = self.settings.main
        main.seekable = ConfigYesNo(default=True)
        main.pausable = ConfigYesNo(default=True)

        log.info('%s successfully loaded', self)
예제 #34
0
    def _get_content_cb(self, success, result):
        log.info(
            '%s get_content_cb - success: %s, items: %d, guicmd: %r - %r' %
            (self, success, len(self.__gui_item_list[0]),
             self.__gui_item_list[1], self.__gui_item_list[2]))

        # resetting timeout for resolving content
        socket.setdefaulttimeout(socket.getdefaulttimeout())

        try:
            ssl._create_default_https_context = CREATE_DEFAULT_HTTPS_CONTEXT
        except:
            pass
        if success:
            lst_itemscp = [[], None, {}]
            lst_itemscp[0] = self.__gui_item_list[0][:]
            lst_itemscp[1] = self.__gui_item_list[1]
            lst_itemscp[2] = self.__gui_item_list[2].copy()
            self.content_deferred.callback(lst_itemscp)
        else:
            self.content_deferred.errback(result)
예제 #35
0
파일: addon.py 프로젝트: puntik1/archivczsk
    def __init__(self, info, repository):
        self.repository = repository
        self.info = info

        self.id = info.id
        self.name = info.name
        self.version = info.version
        self.author = info.author
        self.description = info.description
        self.changelog = info.changelog
        self.path = info.path
        self.relative_path = os.path.relpath(self.path, repository.path)
        self.supported = True

        log.info("%s - initializing", self)

        self._updater = repository._updater
        self.__need_update = False

        # load languages
        self.language = AddonLanguage(
            self,
            os.path.join(self.path, self.repository.addon_languages_relpath))
        if self.language.has_language(settings.LANGUAGE_SETTINGS_ID):
            self.language.set_language(settings.LANGUAGE_SETTINGS_ID)
        else:
            #fix to use czech language instead of slovak language when slovak is not available
            if settings.LANGUAGE_SETTINGS_ID == 'sk' and self.language.has_language(
                    'cs'):
                self.language.set_language('cs')
            else:
                self.language.set_language('en')

        # load settings
        self.settings = AddonSettings(
            self,
            os.path.join(self.path, self.repository.addon_settings_relpath))

        # loader to handle addon imports
        self.loader = AddonLoader(self)
예제 #36
0
 def load_skin():
     try:
         from enigma import getDesktop
         desktop_width = getDesktop(0).size().width()
         log.logDebug("Screen width %s px" % desktop_width)
         if desktop_width >= 1280:
             if DMM_IMAGE:
                 if desktop_width == 1920:
                     skin_default_path = os.path.join(
                         settings.SKIN_PATH, "default_dmm_fhd.xml")
                 elif desktop_width == 3840:
                     skin_default_path = os.path.join(
                         settings.SKIN_PATH, "default_dmm_uhd.xml")
                 else:
                     skin_default_path = os.path.join(
                         settings.SKIN_PATH, "default_dmm_hd.xml")
             else:
                 if desktop_width == 1920:
                     skin_default_path = os.path.join(
                         settings.SKIN_PATH, "default_fhd.xml")
                 elif desktop_width == 3840:
                     skin_default_path = os.path.join(
                         settings.SKIN_PATH, "default_uhd.xml")
                 else:
                     skin_default_path = os.path.join(
                         settings.SKIN_PATH, "default_hd.xml")
         else:
             skin_default_path = os.path.join(settings.SKIN_PATH,
                                              "default_sd.xml")
         skin_name = config.plugins.archivCZSK.skin.value
         skin_path = os.path.join(settings.SKIN_PATH, skin_name + ".xml")
         if skin_name == 'auto' or not os.path.isfile(skin_path):
             skin_path = skin_default_path
         log.info("loading skin %s" % skin_path)
         log.logDebug("loading skin %s" % skin_path)
         loadSkin(skin_path)
     except:
         log.logError("Load plugin skin failed.\n%s" %
                      traceback.format_exc())
         pass
예제 #37
0
    def play_item(self, item=None, idx=None):
        log.info("play_item(%s, %s)" % (item, toString(idx)))
        play_item = None
        if item is not None:
            idx = idx or 0
            if isinstance(item, PPlaylist):
                self.playlist_item = item
                self.playlist = item.playlist
                play_item = item.playlist[idx]
            elif isinstance(item, PVideo):
                if item not in self.playlist:
                    self.playlist_item = None
                    self.playlist = [item]
                play_item = item
        elif idx is not None and self.playlist and idx >= 0 and idx < len(
                self.playlist):
            play_item = self.playlist[idx]

        if play_item is not None and self._play_item != play_item:
            self._play_item = play_item
            self.curr_idx = self.playlist.index(play_item)
            self.play_stream(play_item.url, play_item.settings, play_item.subs,
                             play_item.name, play_item)
예제 #38
0
    def resolve_dependencies(self):
        from Plugins.Extensions.archivCZSK.archivczsk import ArchivCZSK
        log.info("trying to resolve dependencies for %s" , self.video_addon)
        for dependency in self.video_addon.requires:
            addon_id, version, optional = dependency['addon'], dependency['version'], dependency['optional']

            # checking if archivCZSK version is compatible with this plugin
            if addon_id == 'enigma2.archivczsk':
                if  not util.check_version(aczsk.version, version):
                    log.debug("archivCZSK version %s>=%s" , aczsk.version, version)
                else:
                    log.debug("archivCZSK version %s<=%s" , aczsk.version, version)
                    raise AddonError(_("You need to update archivCZSK at least to") + " " + version + " " + _("version"))

            log.info("%s requires %s addon, version %s" , self.video_addon, addon_id, version)
            if ArchivCZSK.has_addon(addon_id):
                tools_addon = ArchivCZSK.get_addon(addon_id)
                log.info("required %s founded" , tools_addon)
                if  not util.check_version(tools_addon.version, version):
                    log.debug("version %s>=%s" , tools_addon.version, version)
                    self._dependencies.append(tools_addon)
                else:
                    log.debug("version %s<=%s" , tools_addon.version, version)
                    if not optional:
                        log.error("cannot execute %s " , self.video_addon)
                        raise AddonError("Cannot execute addon %s, dependency %s version %s needs to be at least version %s"
                                        % (self.video_addon, tools_addon.id, tools_addon.version, version))
                    else:
                        log.debug("skipping")
                        continue
            else:
                log.info("required %s addon not founded" , addon_id)
                if not optional:
                    log.info("cannot execute %s addon" , self.video_addon)
                    raise Exception("Cannot execute %s, missing dependency %s" % (self.video_addon, addon_id))
                else:
                    log.debug("skipping")
예제 #39
0
def add_video(name,
              url,
              subs=None,
              image=None,
              infoLabels={},
              menuItems={},
              filename=None,
              live=False,
              stream=None,
              settings=None,
              dataItem=None):
    """
    adds video item to content screen
        @param url: play url
        @param subs: subtitles url
        @param image: image of video item
        @param infoLabels: dictationary of informations{'title':title,'plot':plot,'rating':rating,''}"
        @param filename: set this filename when downloading
        @param live: is video live stream
        @param settings: dictationary of player/download settings{"user-agent",:"","extra-headers":{}}
    """
    video_it = create_video_it(name=name,
                               url=url,
                               subs=subs,
                               image=image,
                               infoLabels=infoLabels,
                               menuItems=menuItems,
                               filename=filename,
                               live=live,
                               stream=stream,
                               settings=settings,
                               dataItem=dataItem)

    if not isinstance(url, basestring):
        log.info('add_video - ignoring %s, invalid url', repr(video_it))
    else:
        GItem_lst[0].append(video_it)
예제 #40
0
    def play_stream(self,
                    play_url,
                    play_settings=None,
                    subtitles_url=None,
                    title=None):
        log.info("play_stream(%s, %s, %s, %s)" %
                 (play_url, play_settings, subtitles_url, title))
        if play_url.startswith("rtmp"):
            rtmp_timeout = int(self.settings.rtmpTimeout.value)
            rtmp_buffer = int(self.settings.rtmpBuffer.value)
            if ' timeout=' not in play_url:
                play_url = "%s timeout=%d" % (play_url, rtmp_timeout)
            if ' buffer=' not in play_url:
                play_url = "%s buffer=%d" % (play_url, rtmp_buffer)
        headers = {}
        if play_settings.get("user-agent"):
            headers["User-Agent"] = play_settings["user-agent"]
        if play_settings.get("extra-headers"):
            headers.update(play_settings["extra-headers"])
        if headers:
            play_url += "#" + "&".join("%s=%s" % (k, v)
                                       for k, v in headers.iteritems())

        service_ref = eServiceReference(play_settings.get("stype", 4097), 0,
                                        toString(play_url))
        if title is not None:
            service_ref.setName(toString(title))

        if self.video_player is None:
            self.video_player = self.session.openWithCallback(
                self.player_exit_callback, ArchivCZSKMoviePlayer,
                self.player_callback)

        self.video_player.play_service_ref(
            service_ref, self._play_item.subs,
            play_settings.get("resume_time_sec"))
예제 #41
0
 def pause(self):
     if not self.__started:
         log.info("[%s] cannot pause, provider not started yet", self)
         return
     if self.__paused:
         log.info("[%s] cannot pause, provider is already paused", self)
         return
     self.__paused = True
     for f in self.on_pause:
         f()
     log.info("[%s] paused", self)
예제 #42
0
 def resume(self):
     if not self.__started:
         log.info("[%s] cannot resume, provider not started yet", self)
         return
     if not self.__paused:
         log.info("[%s] cannot resume, provider is already running", self)
         return
     self.__paused = False
     for f in self.on_resume:
         f()
     log.info("[%s] resumed", self)
예제 #43
0
    def resolveUrl(self, url):
        log.info("YoutubeDL::resolveUrl '%s'" % (url, ))

        if not self.initialized:
            log.info("YoutubeDL::resolveUrl not initialized...")
            d = Deferred()
            d.callback(None)
            return d
        if self.resolving:
            log.info("YoutubeDL::resolveUrl already resolving url...")
            d = Deferred()
            d.callback(None)
            return d

        self.resolving = True
        self.lastResolvingUrl = url
        self.write({'url': url})

        self.d = Deferred()
        return self.d
예제 #44
0
 def gotResponse(self, response):
     if response['type'] == 'info':
         if response['status']:
             self.initialized = True
             self.available = True
             log.info("YoutubeDL::gotResponse: initialized")
             self.d.callback(True)
         else:
             log.info("YoutubeDL::gotResponse: failed to initialize: %s" %
                      (response['exception'], ))
             self.available = False
             self.d.callback(False)
     elif response['type'] == 'request':
         self.resolving = False
         self.lastResolvingUrl = None
         if response['status']:
             log.info("YoutubeDL::getResponse: url resolved")
             self.d.callback(response['result'])
         else:
             self.d.errback(response['exception'])
예제 #45
0
	def _serviceNotStarted(self, failure):
		log.info('cannot get service reference')
예제 #46
0
    def createDownload(self,
                       name,
                       url,
                       destination,
                       filename=None,
                       live=False,
                       startCB=None,
                       finishCB=None,
                       stream=None,
                       quiet=False,
                       playDownload=False,
                       headers=None,
                       mode=""):
        log.info("Downloader.createDownload(url=%s,mode=%s" %
                 (toString(url), mode))
        #log.logDebug("Creating download\name=%s\nurl=%s\ndestination=%s\nfilename=%s\nheaders=%s\nmode=%s" % (name, url, destination, filename, headers, mode))
        d = None
        if headers is None:
            headers = {}
        try:
            headers = headers.copy()
        except:
            log.logError(
                "Copy headers for download failed, continute download.\n%s" %
                traceback.format_exc())
            headers = {}
            pass
        from Plugins.Extensions.archivCZSK.settings import USER_AGENT
        headers.setdefault('User-Agent', USER_AGENT)
        filename, length = getFilenameAndLength(url, headers, filename)
        log.info("Downloader.createDownload() filename=%s, length=%s",
                 toString(filename), length)
        if (((url[0:4] == 'rtmp' and mode in ('auto', 'gstreamer')) or
             (url[0:4] == 'http' and mode in ('auto', 'gstreamer')
              and isHLSUrl(url)) or
             (url[0:4] == 'http' and mode in ('auto', 'gstreamer')
              and playDownload) or
             (url[0:4] == 'http' and mode in ('gstreamer', )))
                and GST_LAUNCH is not None):
            d = GstDownload(url=url,
                            name=name,
                            destDir=destination,
                            filename=filename,
                            headers=headers)
        elif url[0:4] == 'rtmp' and mode in ('auto', 'rtmpdump'):
            urlList = url.split()
            rtmp_url = []
            for url in urlList[1:]:
                rtmp = url.split('=', 1)
                rtmp_url.append(' --' + rtmp[0])
                rtmp_url.append("'%s'" % rtmp[1])
            url = "'%s'" % urlList[0] + ' '.join(rtmp_url)
            if not live:
                realtime = True
            else:
                realtime = False
            d = RTMPDownloadE2(url=url,
                               name=name,
                               destDir=destination,
                               filename=filename,
                               live=live,
                               quiet=quiet,
                               realtime=realtime)
        elif url[0:4] == 'http':
            if isHLSUrl(url):
                raise NotSupportedProtocolError('HLS')
            d = HTTPDownloadE2(name=name,
                               url=url,
                               filename=filename,
                               destDir=destination,
                               quiet=quiet,
                               headers=headers)
        else:
            protocol = url.split('://')[0].upper()
            log.error(
                'Downloader.createDownload() - not supported protocol %s' %
                toString(protocol))
            raise NotSupportedProtocolError(protocol)

        if startCB is not None:
            d.onStartCB.append(startCB)
        if finishCB is not None:
            d.onFinishCB.append(finishCB)
        d.status = DownloadStatus(d)
        d.length = length or 0
        return d
예제 #47
0
    def __init__(self, info_file):
        log.info("initializing info of addon from %s", info_file)

        pars = parser.XBMCAddonXMLParser(info_file)
        addon_dict = pars.parse()

        self.id = addon_dict['id']
        self.name = addon_dict['name']
        self.version = addon_dict['version']
        self.author = addon_dict['author']
        self.type = addon_dict['type']
        self.broken = addon_dict['broken']
        self.path = os.path.dirname(info_file)
        self.library = addon_dict['library']
        self.script = addon_dict['script']
        self.tmp_path = settings.TMP_PATH
        self.data_path = os.path.join(
            config.plugins.archivCZSK.dataPath.getValue(), self.id)
        self.profile = self.data_path

        # create data_path(profile folder)
        util.make_path(self.data_path)

        if settings.LANGUAGE_SETTINGS_ID in addon_dict['description']:
            self.description = addon_dict['description'][
                settings.LANGUAGE_SETTINGS_ID]
        elif settings.LANGUAGE_SETTINGS_ID == 'sk' and 'cs' in addon_dict[
                'description']:
            self.description = addon_dict['description']['cs']
        else:
            if not 'en' in addon_dict['description']:
                self.description = u''
            else:
                self.description = addon_dict['description']['en']

        self.requires = addon_dict['requires']
        self.image = os.path.join(self.path, 'icon.png')

        #changelog
        changelog_path = None
        if os.path.isfile(os.path.join(self.path, 'changelog.txt')):
            changelog_path = os.path.join(self.path, 'changelog.txt')

        elif os.path.isfile(os.path.join(self.path, 'Changelog.txt')):
            changelog_path = os.path.join(self.path, 'Changelog.txt')

        else:
            changelog_path = None

        if changelog_path is not None:
            with open(changelog_path, 'r') as f:
                text = f.read()
            try:
                self.changelog = text.decode('windows-1250')
            except Exception:
                log.debug('cannot decode c[C]angleog.txt')
                self.changelog = u''
                pass
        else:
            log.debug('c[C]hangelog.txt missing')
            self.changelog = u''
예제 #48
0
 def processExited(self, retval):
     log.info("YoutubeDL::processExited: process exited %d" % (retval))
예제 #49
0
 def __init__(self):
     self.vpsp = VideoPlaySettingsProvider()
     log.info("Loading %s", self.__class__.__name__)
예제 #50
0
    def load_streams(self):
        groups = []
        self.stream_root = util.load_xml(self.streams_path)

        for group in self.stream_root.findall('group'):
            group_name = ''
            group_name = group.findtext('name')
            cat_channels = []

            for channel in group.findall('channel'):
                name = channel.findtext('name')
                stream_url = channel.findtext(
                    'stream_url') or channel.findtext('streamUrl')
                picon = channel.findtext('picon')
                app = channel.findtext('app')
                swf_url = channel.findtext('swfUrl')
                page_url = channel.findtext('pageUrl')
                playpath = channel.findtext('playpath')
                advanced = channel.findtext('advanced')
                live_stream = channel.findtext(
                    'liveStream') or channel.findtext('live_stream')
                player_buffer = channel.findtext(
                    'playerBuffer') or channel.findtext('player_buffer')
                rtmp_buffer = channel.findtext(
                    'rtmpBuffer') or channel.findtext('rtmp_buffer')
                play_delay = channel.findtext('playDelay') or channel.findtext(
                    'play_delay')
                rtmp_timeout = channel.findtext('timeout')

                if name is None or stream_url is None:
                    log.info('skipping stream, cannot find name or url')
                    continue
                if picon is None: pass
                if app is None: app = u''
                if playpath is None: playpath = u''
                if swf_url is None: swf_url = u''
                if page_url is None: page_url = u''
                if advanced is None: advanced = u''
                if live_stream is None: live_stream = True
                else: live_stream = not live_stream == 'False'
                if rtmp_buffer is None:
                    rtmp_buffer = int(config.plugins.archivCZSK.videoPlayer.
                                      liveBuffer.getValue())
                if rtmp_timeout is None:
                    rtmp_timeout = int(config.plugins.archivCZSK.videoPlayer.
                                       rtmpTimeout.getValue())
                if player_buffer is None:
                    player_buffer = int(config.plugins.archivCZSK.videoPlayer.
                                        bufferSize.getValue())
                if play_delay is None:
                    play_delay = int(config.plugins.archivCZSK.videoPlayer.
                                     playDelay.getValue())

                if stream_url.startswith('rtmp'):
                    stream = RtmpStream(stream_url, app, playpath, page_url,
                                        swf_url, advanced)
                    stream.buffer = int(rtmp_buffer)
                    stream.timeout = int(rtmp_timeout)
                else:
                    stream = Stream(stream_url)

                stream.picon = picon
                stream.playBuffer = int(player_buffer)
                stream.playDelay = int(play_delay)
                stream.live = live_stream

                it = PVideo()
                it.name = name
                it.url = stream_url
                it.live = live_stream
                it.stream = stream
                it.xml = channel
                it.root_xml = group
                cat_channels.append(it)

            playlist = PPlaylist()
            playlist.name = group_name
            playlist.playlist = cat_channels[:]
            #cat_channels.insert(0, playlist)
            it = PFolder()
            it.name = group_name
            it.xml = group
            it.channels = cat_channels
            groups.append(playlist)

        self.groups = groups
예제 #51
0
 def remove_download(self, item):
     if item is not None and isinstance(item, PDownload):
         log.debug('removing item %s from disk' % item.name)
         os.remove(item.path.encode('utf-8'))
     else:
         log.info('cannot remove item %s from disk, not PDownload instance', str(item))
예제 #52
0
    def __init__(self, config_file):
        log.info("initializing repository from %s", config_file)
        pars = parser.XBMCAddonXMLParser(config_file)
        repo_dict = pars.parse()

        self.id = repo_dict['id']
        self.name = repo_dict['name']
        self.author = repo_dict['author']
        self.version = repo_dict['version']
        self.description = repo_dict['description']
        # every repository should have its update xml, to check versions and update/download addons
        self.update_xml_url = repo_dict['repo_addons_url']

        self.update_datadir_url = repo_dict['repo_datadir_url']

        self.path = os.path.dirname(config_file)
        self.addons_path = self.path  #os.path.join(self.path, "addons")

        # addon.xml which describes addon
        self.addon_xml_relpath = 'addon.xml'

        # icon for addon size 256x256
        self.addon_icon_relpath = 'icon.png'

        self.addon_resources_relpath = 'resources'

        # default language,settings and libraries path of addon
        self.addon_languages_relpath = self.addon_resources_relpath + '/language'
        self.addon_settings_relpath = self.addon_resources_relpath + '/settings.xml'
        self.addon_libraries_relpath = self.addon_resources_relpath + '/lib'

        self._addons = {}

        #create updater for repository
        self._updater = updater.Updater(
            self, os.path.join(settings.TMP_PATH, self.id))

        # load installed addons in repository
        for addon_dir in os.listdir(self.addons_path):
            addon_path = os.path.join(self.addons_path, addon_dir)
            if os.path.isfile(addon_path):
                continue

            addon_info = AddonInfo(
                os.path.join(addon_path, self.addon_xml_relpath))
            if addon_info.type not in Repository.SUPPORTED_ADDONS:
                raise Exception(
                    "%s '%s' addon not in supported type of addons %s " %
                    (self, addon_info.type, Repository.SUPPORTED_ADDONS))
            if addon_info.type == 'video':
                try:
                    addon = VideoAddon(addon_info, self)
                except Exception:
                    traceback.print_exc()
                    log.info("%s cannot load video addon %s", self, addon_dir)
                    log.info("skipping")
                    continue
                else:
                    archivczsk.ArchivCZSK.add_addon(addon)
                    self.add_addon(addon)

            elif addon_info.type == 'tools':
                # load tools addons
                try:
                    tools = ToolsAddon(addon_info, self)
                except Exception:
                    traceback.print_exc()
                    log.info("%s cannot load tools addon %s", self, addon_dir)
                    log.info("skipping")
                    continue
                else:
                    archivczsk.ArchivCZSK.add_addon(tools)
                    self.add_addon(tools)
        log.info("%s successfully loaded", self)
예제 #53
0
 def doEofInternal(self, playing):
     log.info("doEofInternal(%s)" % playing)
     self.player_callback(("eof", playing))
예제 #54
0
파일: addon.py 프로젝트: firo11/archivczsk
    def __init__(self, info_file):
        log.info("AddonInfo(%s) initializing..",
                 '/'.join(info_file.split('/')[-3:]))

        pars = parser.XBMCAddonXMLParser(info_file)
        addon_dict = pars.parse()

        self.id = addon_dict['id']
        self.name = addon_dict['name']
        self.version = addon_dict['version']
        self.author = addon_dict['author']
        self.type = addon_dict['type']
        self.broken = addon_dict['broken']
        self.path = os.path.dirname(info_file)
        self.library = addon_dict['library']
        self.script = addon_dict['script']
        self.tmp_path = config.plugins.archivCZSK.tmpPath.value
        self.data_path = os.path.join(
            config.plugins.archivCZSK.dataPath.getValue(), self.id)
        self.profile = self.data_path

        # create data_path(profile folder)
        util.make_path(self.data_path)

        if settings.LANGUAGE_SETTINGS_ID in addon_dict['description']:
            self.description = addon_dict['description'][
                settings.LANGUAGE_SETTINGS_ID]
        elif settings.LANGUAGE_SETTINGS_ID == 'sk' and 'cs' in addon_dict[
                'description']:
            self.description = addon_dict['description']['cs']
        else:
            if not 'en' in addon_dict['description']:
                self.description = u''
            else:
                self.description = addon_dict['description']['en']

        self.requires = addon_dict['requires']
        self.image = os.path.join(self.path, 'icon.png')

        #changelog
        changelog_path = None
        if os.path.isfile(os.path.join(self.path, 'changelog.txt')):
            changelog_path = os.path.join(self.path, 'changelog.txt')

        elif os.path.isfile(os.path.join(self.path, 'Changelog.txt')):
            changelog_path = os.path.join(self.path, 'Changelog.txt')

        else:
            changelog_path = None

        if changelog_path is not None:
            with open(changelog_path, 'r') as f:
                text = f.read()
            try:
                self.changelog = text
            except Exception:
                log.error('%s c[C]angleog.txt cannot be decoded', self)
                self.changelog = u''
                pass
        else:
            log.error('%s c[C]hangelog.txt file is missing', self)
            self.changelog = u''
예제 #55
0
 def write(self, data):
     log.info(data)