Ejemplo n.º 1
0
  def onPlayBackStarted(self):
    addon_log('START')
    addon_log(xbmc.getInfoLabel('VideoPlayer.VideoCodec'))
    addon_log(xbmc.getInfoLabel('VideoPlayer.AudioCodec'))

    ## this will kill the sopcast if we changed the media
    #if xbmc.Player(xbmc.PLAYER_CORE_AUTO).getPlayingFile() != SETTINGS.LOCAL_URL:
    #  try: stop_spsc(self.spsc_pid)
    #  except: pass
    xbmc.executebuiltin( "Dialog.Close(busydialog)" )

    #online notif
    mark = mark_stream(ch_id=self.ch_id)
    mark.mark_online()
    self.stream_online = True

    if SETTINGS.DISABLE_SCHEDULE!='true':
      #display schedule active event
      epgObj = epg()
      active_event = epgObj.load_active_event(self.name)
      if active_event:
        active_event = active_event.encode('utf8')
        xbmc.executebuiltin("Notification(%s,%s,%i)" % (active_event, "", 10000))
Ejemplo n.º 2
0
def STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id):
  if(url == None):
    try: xbmc.executebuiltin("Dialog.Close(all,true)")
    except: pass
    return False

  if (sch_ch_id != None) and (SETTINGS.DISABLE_SCHEDULE != 'true'):
    epgObj = epg()
    epgObj.grab_schedule(sch_ch_id, name)

  #addon_log(name)
  #addon_log(iconimage)

  if not iconimage or iconimage == "": iconimage="DefaultVideo.png"
  listitem = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
  #listitem.setLabel(name)
  listitem.setInfo('video', {'Title': name})

  player = streamplayer(name=name, protocol=protocol, ch_id=ch_id)

  #play sopcast stream
  if protocol == "sop":
    if(SETTINGS.USE_PLEXUS_SOP == 'true'):
      try:
        addon_log('plexus')
        xbmc.executebuiltin('XBMC.RunPlugin(plugin://program.plexus/?mode=2&url='+url+'&name='+name+'&iconimage='+iconimage+')')
      except Exception as inst:
        addon_log(inst)
        xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30303), "", 10000))
    else:
      sop = sopcast(player=player, url=url, listitem=listitem)
      sop.start()

  #play acestream
  elif protocol=='acestream':
    if(SETTINGS.ACE_ENGINE_TYPE == 2): #use plexus
      try:
        addon_log('plexus')
        xbmc.executebuiltin('XBMC.RunPlugin(plugin://program.plexus/?mode=1&url='+url+'&name='+name+'&iconimage='+iconimage+')')
      except Exception as inst:
        addon_log(inst)
        xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30303), "", 10000))
    elif(SETTINGS.ACE_ENGINE_TYPE == 1): #use external
      #play with acestream engine started on another machine or on the localhost
      ace = acestream(player=player, url=url, listitem=listitem)
      ace.engine_connect()
    # else: #use internal
    #   if xbmc.getCondVisibility('System.Platform.Android'):
    #       #xbmc.executebuiltin("Notification(%s,%s,%i)" % ("android", "", 3000))
    #       ace = acestream(player=player, url=url, listitem=listitem)
    #       ace.engine_connect()
    #   elif xbmc.getCondVisibility('system.platform.linux'):
    #       #xbmc.executebuiltin("Notification(%s,%s,%i)" % ("linux", "", 3000))
    #       addon_log('linux')
    #       addon_log(os.uname())
    #       if "aarch" in os.uname()[4]:
    #           addon_log('aarch')
    #           #xbmc.executebuiltin("Notification(%s,%s,%i)" % ("aarch", "", 3000))
    #           if not os.path.isfile(os.path.join(fileslist,"acestream","chroot")):
    #               arch = '64' if sys.maxsize > 2**32 else '32'
    #               acestream_pack = "https://raw.githubusercontent.com/viorel-m/kingul-repo/master/acestream/acestream_arm%s.tar.gz" % arch
    #               acekit(acestream_pack)
    #           import acestream as ace
    #           ace.acestreams_builtin(name,iconimage,url)
    #       elif "arm" in os.uname()[4]:
    #           addon_log('arm')
    #           if not os.path.isfile(os.path.join(fileslist,"acestream","chroot")):
    #               acestream_pack = "https://raw.githubusercontent.com/viorel-m/kingul-repo/master/acestream/acestream_arm32.tar.gz"
    #               acekit(acestream_pack)
    #           import acestream as ace
    #           ace.acestreams_builtin(name,iconimage,url)

  #play direct stream
  else:
    try:
      player.play(url, listitem)
    except Exception as inst:
      xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)),str(inst),"")
      try: xbmc.executebuiltin("Dialog.Close(all,true)")
      except: pass
Ejemplo n.º 3
0
def CHANNEL_LIST(name, cat_id, mode=None, schedule=False):
  if (SETTINGS.DISABLE_SCHEDULE != 'true'):
    epgObj = epg()

  addon_log(name);
  rec = []
  try:
    sql = 'SELECT id, name, language, status, \
           address, thumbnail, protocol, \
           schedule_id, unverified \
           FROM channels \
           WHERE id_cat = ?'
    if((mode!=None) and (int(mode)==101)):
      sql += ' and unverified = 1'
    else:
      sql += ' and unverified IS NULL'
    sql += ' ORDER BY name'
    db_cursor.execute( sql, (cat_id,) )
    rec=db_cursor.fetchall()
  except Exception as inst:
    addon_log(inst)
    xbmcgui.Dialog().ok(addon.getLocalizedString(30300), addon.getLocalizedString(30301), str(inst))  #Cannot parse channel list !

  if len(rec)>0:
    for id, name, language, status, \
        address, thumbnail, protocol, \
        schedule_id, unverified in rec:

      #filter by country and language
      #if( (((country != '') and (addon.getSetting('country_'+country) == 'true')) or
           #((country == '') and (addon.getSetting('country_none') == 'true')) ) and
           #(((language != '') and (addon.getSetting('lang_'+language) == 'true')) or
           #((language == '') and (addon.getSetting('lang_none') == 'true')) )
        #):

      chan_name = name
      chan_url = address.strip()

      protocol = protocol.strip()
      #if protocol=='sop':
      #  protocol_color = '[COLOR lightgreen]'+protocol+'[/COLOR]'
      #else:
      #  protocol_color = '[COLOR yellow]'+protocol+'[/COLOR]'

      chan_thumb = thumbnail.strip()
      #addon_log(chan_thumb)
      chan_status = status

      if (((SETTINGS.SHOW_OFFLINE_CH=='true') and (int(chan_status)==1)) or (int(chan_status)!=1)): #if we show or not offline channels based on settings
        logo_name = chan_name.replace(' ', '').lower()
        logo_name = logo_name.encode('utf8')

        chan_name_formatted ="[B]"+chan_name+"[/B]"
        chan_name_formatted += " [[COLOR yellow]"+protocol+"[/COLOR]]"

        if int(chan_status)==1: chan_name_formatted += " [COLOR red]"+addon.getLocalizedString(30063)+"[/COLOR]"  #Offline

        thumb_path=""
        if chan_thumb and chan_thumb != "":
          fileName, fileExtension = os.path.splitext(chan_thumb)
          fileName=fileName.split("/")[-1]

          logoDir = os.path.join(SETTINGS.ADDON_PATH,"logos");
          #create logos directory if does not exists
          if(not os.path.isdir(logoDir)):
            os.makedirs(logoDir)

          if fileName != "":
            #thumb_path=os.path.join(ADDON_PATH,"logos",fileName+fileExtension)
            fileExtension = fileExtension.encode('utf8')
            thumb_path=os.path.join(logoDir,logo_name+fileExtension)

          if not os.path.isfile(thumb_path):
            if fileName != "":
              try:
                Downloader(chan_thumb, thumb_path, fileName+fileExtension, addon.getLocalizedString(30055)) #Downloading Channel Logo
              except Exception as inst:
                pass;

        #schedule
        if (schedule_id != 0) and \
            (schedule or (addon.getSetting('schedule_ch_list') == 'true')) \
            and (SETTINGS.DISABLE_SCHEDULE != 'true'):
          if (schedule): #update all by context menu
            update_all = True
          elif(addon.getSetting('schedule_ch_list') == 'true'): #update all when we display channel list
            update_all = False
          #addon_log('grab_schedule')
          epgObj.grab_schedule(schedule_id, chan_name, update_all=update_all)

        if (SETTINGS.DISABLE_SCHEDULE != 'true') and (int(cat_id) < 200):
          schedule_txt = epgObj.load_schedule(chan_name)
          chan_name_formatted += "   " + schedule_txt

        addLink(id, chan_name_formatted, chan_name, chan_url, protocol, str(schedule_id),
                name, cat_id, 2, thumb_path, "", len(rec))

  xbmc.executebuiltin("Container.SetViewMode(51)")
Ejemplo n.º 4
0
    if cat_id == "200" :
      url = grab_vk_stream(name, url)
    if cat_id == "201" or cat_id == "202" :
      url = grab_fu_stream(name, url)
    STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id)
  else:
    #stop_spsc()
    xbmc.executebuiltin( "ActivateWindow(busydialog)" )
    if cat_id == "200" :
      url = grab_vk_stream(name, url)
    if cat_id == "201" or cat_id == "202" :
      url = grab_fu_stream(name, url)
    STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id)
elif mode==3:  #refresh schedule
  if sch_ch_id != None:
    epgObj = epg()
    epgObj.grab_schedule(sch_ch_id, name, force=True)
    xbmc.executebuiltin('Container.Refresh()')
elif mode==4:  #refresh channel list
  CAT_LIST(force=True)
  xbmc.executebuiltin('Container.Refresh()')
elif mode==5:  #refresh all schedules
  CHANNEL_LIST(name=name, cat_id=cat_id, schedule=True)
  xbmc.executebuiltin('Container.Refresh()')
#elif mode==6:  #EPG
#  addon_log('epg');
#  mydisplay = EPG("custom_help.xml",ADDON_PATH)
#  mydisplay.doModal()
#  del mydisplay

db_connection.close()