Ejemplo n.º 1
0
static void
tmdb_insert_movie_cast(void *db, int64_t itemid, htsmsg_t *doc)
{
  char url[300];
  char id[64];
  htsmsg_field_t *f;
  const char *s;

  htsmsg_t *cast = htsmsg_get_list(doc, "cast");
  HTSMSG_FOREACH(f, cast) {
    htsmsg_t *p = htsmsg_get_map_by_field(f);
    if(p == NULL)
      continue;

    s = htsmsg_get_str(p, "profile_path");
    if(s)
      snprintf(url, sizeof(url), "tmdb:image:profile:%s", s);
    else
      url[0] = 0;

    snprintf(id, sizeof(id), "%d", htsmsg_get_u32_or_default(p, "id", 0));

    metadb_insert_videocast(db, itemid,
			    htsmsg_get_str(p, "name"),
			    htsmsg_get_str(p, "character"),
			    "Cast",
			    "Actor",
			    htsmsg_get_u32_or_default(p, "order", 0),
			    url[0] ? url : NULL, 0, 0,
			    id);
  }
Ejemplo n.º 2
0
static JSBool 
js_appendItem(JSContext *cx, JSObject *obj, uintN argc,
	      jsval *argv, jsval *rval)
{
  const char *url;
  const char *type = NULL;
  JSObject *metaobj = NULL;
  js_model_t *model = JS_GetPrivate(cx, obj);
  const char *canonical_url = NULL;
  htsmsg_t *m = NULL;
  JSBool r;

  if(!JS_ConvertArguments(cx, argc, argv, "s/so", &url, &type, &metaobj))
    return JS_FALSE;

  if(!strncmp(url, "videoparams:", strlen("videoparams:"))) {
    m = htsmsg_json_deserialize(url + strlen("videoparams:"));
    if(m != NULL) {
      canonical_url = htsmsg_get_str(m, "canonicalUrl");

      if(canonical_url == NULL) {
	htsmsg_t *sources;
	if((sources = htsmsg_get_list(m, "sources")) == NULL) {
	  htsmsg_field_t *f;
	  HTSMSG_FOREACH(f, sources) {
	    htsmsg_t *src = &f->hmf_msg;
	    canonical_url = htsmsg_get_str(src, "url");
	    if(canonical_url != NULL)
	      break;
	  }
Ejemplo n.º 3
0
static void
http_callback(http_req_aux_t *req, void *opaque)
{
  char errbuf[128];
  tracker_torrent_t *tt = opaque;
  torrent_t *to = tt->tt_torrent;
  htsmsg_t *msg;
  net_addr_t na;

  assert(tt->tt_http_req != NULL);
  tt->tt_http_req = NULL;

  buf_t *b = http_req_get_result(req);

  tt->tt_interval = MIN(3600, tt->tt_interval * 2);

  if(b != NULL) {
    msg = bencode_deserialize(buf_cstr(b),
                              buf_cstr(b) + buf_size(b),
                              errbuf, sizeof(errbuf), NULL, NULL);
    if(msg != NULL) {

      const char *err = htsmsg_get_str(msg, "failure reason");
      if(err != NULL) {
        tracker_trace(tt->tt_tracker, "%s for %s", err, to->to_title);
        goto done;
      }

      const char *trackerid = htsmsg_get_str(msg, "trackerid");

      if(trackerid != NULL)
        mystrset(&tt->tt_trackerid, trackerid);

      tt->tt_interval =
        htsmsg_get_u32_or_default(msg, "min interval",
                                  htsmsg_get_u32_or_default(msg,
                                                            "interval", 1800));

      htsmsg_t *peers = htsmsg_get_list(msg, "peers");
      if(peers != NULL) {
        htsmsg_field_t *f;
        HTSMSG_FOREACH(f, peers) {
          htsmsg_t *sub = htsmsg_get_map_by_field(f);
          if(sub == NULL)
            continue;
          const char *ip = htsmsg_get_str(sub, "ip");
          if(ip == NULL)
            continue;

          if(net_resolve_numeric(ip, &na))
            continue;

          na.na_port = htsmsg_get_u32_or_default(sub, "port", 0);
          if(na.na_port == 0)
            continue;
          peer_add(to, &na);
        }
      }
Ejemplo n.º 4
0
static int
dotdoozer_parse(job_t *j, htsmsg_t *target)
{
  SHA_CTX ctx;
  uint8_t digest[20];

  const char *buildenv = htsmsg_get_str(target, "buildenv");
  if(buildenv == NULL)
    return 0;

  cfg_root(root);
  const char *source = cfg_get_str(root, CFG("buildenvs", buildenv, "source"),
                                   NULL);
  if(source == NULL) {
    snprintf(j->errmsg, sizeof(j->errmsg), "Don't know about buildenv: %s",
             buildenv);
    return DOOZER_PERMANENT_FAIL;
  }

  // We are going to build in a chroot
  j->projectdir_internal = "/project";

  j->buildenv_source = tstrdup(source);

  // Compute SHA1 of source URL, this is the source ID

  SHA1((void *)source, strlen(source), digest);
  bin2hex(j->buildenv_source_id, sizeof(j->buildenv_source_id),
          digest, sizeof(digest));

  // Compute SHA1 of source URL + all build deps, this is the modified ID

  SHA1_Init(&ctx);
  SHA1_Update(&ctx, source, strlen(source));
  htsmsg_t *builddeps = htsmsg_get_list(target, "builddeps");
  if(builddeps != NULL) {

    htsmsg_field_t *f;

    int count = 0;
    HTSMSG_FOREACH(f, builddeps) {
      if(f->hmf_type != HMF_STR) {
        snprintf(j->errmsg, sizeof(j->errmsg),
                 "Not all builddeps are strings");
        return DOOZER_PERMANENT_FAIL;
      }
      count++;
    }

    j->num_builddeps = count;

    const char **bds = talloc_zalloc(count * sizeof(char *));
    count = 0;
    HTSMSG_FOREACH(f, builddeps) {
      bds[count++] = tstrdup(f->hmf_str);
      SHA1_Update(&ctx, f->hmf_str, strlen(f->hmf_str));
    }
Ejemplo n.º 5
0
static int
count_list(htsmsg_t *m, const char *fname)
{
  htsmsg_t *l = htsmsg_get_list(m, fname);
  if(l == NULL)
    return 0;
  htsmsg_field_t *f;
  int cnt = 0;
  HTSMSG_FOREACH(f, l)
    cnt++;
  return cnt;
}
Ejemplo n.º 6
0
static void
addsizes(tmdb_image_size_t **p, htsmsg_t *img, const char *field, float aspect)
{
  htsmsg_t *l = htsmsg_get_list(img, field);
  htsmsg_field_t *f;
  if(l == NULL)
    return;

  HTSMSG_FOREACH(f, l) {
    if(f->hmf_type == HMF_STR)
      addsize(p, f->hmf_str, aspect);
  }
}
Ejemplo n.º 7
0
static int
api_dvr_autorec_create_by_series
  ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
  dvr_autorec_entry_t *dae;
  epg_broadcast_t *e;
  htsmsg_t *entries, *entries2 = NULL, *m;
  htsmsg_field_t *f;
  const char *config_uuid, *s;
  int count = 0;

  if (!(entries = htsmsg_get_list(args, "entries"))) {
    entries = entries2 = api_dvr_entry_create_from_single(args);
    if (!entries)
      return EINVAL;
  }

  HTSMSG_FOREACH(f, entries) {
    if (!(m = htsmsg_get_map_by_field(f))) continue;

    if (!(s = htsmsg_get_str(m, "event_id")))
      continue;

    config_uuid = htsmsg_get_str(m, "config_uuid");

    pthread_mutex_lock(&global_lock);
    if ((e = epg_broadcast_find_by_id(strtoll(s, NULL, 10)))) {
      dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid);
      if (cfg) {
        dae = dvr_autorec_add_series_link(idnode_uuid_as_str(&cfg->dvr_id),
                                          e,
                                          perm->aa_username,
                                          perm->aa_representative,
                                          "Created from EPG query");
        if (dae) {
          dvr_autorec_save(dae);
          dvr_autorec_changed(dae, 1);
        }
      }
    }
    pthread_mutex_unlock(&global_lock);
    count++;
  }

  htsmsg_destroy(entries2);

  return !count ? EINVAL : 0;
}
Ejemplo n.º 8
0
static void
update_events(htsp_connection_t *hc, prop_t *metadata, int id, int next)
{
  int i;
  htsmsg_t *m;
  prop_t *events        = prop_create(metadata, "list");
  prop_t *current_event = prop_create(metadata, "current");
  prop_t *next_event    = prop_create(metadata, "next");
  int linkstate = 0;
  htsmsg_field_t *f;

  if(id == 0) {

    if(next == 0) {
      // No events at all
      prop_destroy_childs(events);
      return;
    }
    
    id = next;
    linkstate = 1;
  }

  m = htsmsg_create_map();
  htsmsg_add_str(m, "method", "getEvents");
  htsmsg_add_u32(m, "eventId", id);
  htsmsg_add_u32(m, "numFollowing", EPG_TAIL);

  if((m = htsp_reqreply(hc, m)) != NULL) {

    htsmsg_t *events = htsmsg_get_list(m, "events");
    f = events ? TAILQ_FIRST(&events->hm_fields) : NULL;

  } else {
    f = NULL;
  }


  for(i = 0; i < EPG_TAIL; i++) {
    char buf[10];
    uint32_t u32;
    snprintf(buf, sizeof(buf), "%d", i);

    if(f != NULL && f->hmf_type != HMF_MAP)
      f = NULL;

    if(f != NULL) {

      m = htsmsg_get_map_by_field(f);

      prop_t *e = prop_create(events, buf);
      prop_set_string(prop_create(e, "title"), htsmsg_get_str(m, "title"));
      prop_set_string(prop_create(e, "description"),
		      htsmsg_get_str(m, "description"));
      if(!htsmsg_get_u32(m, "start", &u32))
	prop_set_int(prop_create(e, "start"), u32);
      
      if(!htsmsg_get_u32(m, "stop", &u32))
	prop_set_int(prop_create(e, "stop"), u32);
      
      switch(linkstate) {
      case 0:
	prop_link(e, current_event);
	break;
      case 1:
	prop_link(e, next_event);
	break;
      }
      linkstate++;

      f = TAILQ_NEXT(f, hmf_link);
      continue;
    }
    prop_destroy_by_name(events, buf);

    switch(linkstate) {
    case 0:
      prop_unlink(current_event);
      break;
    case 1:
      prop_unlink(next_event);
      break;
    }
    linkstate++;
  }
}
Ejemplo n.º 9
0
    snprintf(id, sizeof(id), "%d", htsmsg_get_u32_or_default(p, "id", 0));

    metadb_insert_videocast(db, itemid,
			    htsmsg_get_str(p, "name"),
			    htsmsg_get_str(p, "character"),
			    "Cast",
			    "Actor",
			    htsmsg_get_u32_or_default(p, "order", 0),
			    url[0] ? url : NULL, 0, 0,
			    id);
  }



  htsmsg_t *crew = htsmsg_get_list(doc, "crew");
  int o = 0;
  HTSMSG_FOREACH(f, crew) {
    htsmsg_t *p = htsmsg_get_map_by_field(f);
    if(p == NULL)
      continue;

    s = htsmsg_get_str(p, "profile_path");
    if(s)
      snprintf(url, sizeof(url), "tmdb:image:profile:%s", s);
    else
      url[0] = 0;

    snprintf(id, sizeof(id), "%d", htsmsg_get_u32_or_default(p, "id", 0));

    metadb_insert_videocast(db, itemid,
Ejemplo n.º 10
0
static int
md_props(htsbuf_queue_t *hq, htsmsg_t *m, const char *lang, int nl)
{
  htsmsg_t *l, *n, *e, *x;
  htsmsg_field_t *f, *f2;
  const char *s;
  int first = 1, b;

  l = htsmsg_get_list(m, "props");
  HTSMSG_FOREACH(f, l) {
    n = htsmsg_field_get_map(f);
    if (!n) continue;
    if (!htsmsg_get_bool(n, "noui", &b) && b) continue;
    s = htsmsg_get_str(n, "caption");
    if (!s) continue;
    if (first) {
      nl = md_nl(hq, nl);
      htsbuf_append_str(hq, "#### ");
      htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("Items")));
      md_nl(hq, 1);
      md_nl(hq, 1);
      htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("The items have the following functions:")));
      md_nl(hq, 1);
      first = 0;
    }
    nl = md_nl(hq, nl);
    md_style(hq, "**", s);
    if (!htsmsg_get_bool(n, "rdonly", &b) && b) {
      htsbuf_append(hq, " _", 2);
      htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("(Read-only)")));
      htsbuf_append(hq, "_", 1);
    }
    md_nl(hq, 1);
    s = htsmsg_get_str(n, "description");
    if (s) {
      md_text(hq, ": ", "  ", s);
      md_nl(hq, 1);
    }
    s = htsmsg_get_str(n, "doc");
    if (s) {
      htsbuf_append_str(hq, s);
      md_nl(hq, 1);
    }
    if (!htsmsg_get_bool_or_default(n, "doc_nlist", 0)) {
      e = htsmsg_get_list(n, "enum");
      if (e) {
        HTSMSG_FOREACH(f2, e) {
          x = htsmsg_field_get_map(f2);
          if (x) {
            s = htsmsg_get_str(x, "val");
          } else {
            s = htsmsg_field_get_string(f2);
          }
          if (s) {
            md_nl(hq, 1);
            htsbuf_append(hq, "  * ", 4);
            md_style(hq, "**", s);
          }
        }
        md_nl(hq, 1);
      }
Ejemplo n.º 11
0
void
load_site_news(void)
{
#if ENABLE_WEBPOPUP
  struct http_header_list response_headers;
  buf_t *b;
  char errbuf[512];
  b = fa_load("https://movian.tv/projects/movian/news.json",
              FA_LOAD_FLAGS(FA_DISABLE_AUTH | FA_COMPRESSION),
              FA_LOAD_RESPONSE_HEADERS(&response_headers),
              FA_LOAD_ERRBUF(errbuf, sizeof(errbuf)),
              NULL);
  if(b == NULL) {
    TRACE(TRACE_DEBUG, "News", "Unable to load news -- %s", errbuf);
    return;
  }

  const char *dateheader = http_header_get(&response_headers, "date");
  if(dateheader == NULL) {
    buf_release(b);
    http_headers_free(&response_headers);
    return;
  }
  dateheader = mystrdupa(dateheader);
  http_headers_free(&response_headers);


  htsmsg_t *newsinfo = htsmsg_store_load("sitenews");
  time_t no_news_before;

  if(newsinfo == NULL)
    newsinfo = htsmsg_create_map();

  no_news_before = htsmsg_get_u32_or_default(newsinfo, "nothingbefore", 0);

  if(no_news_before == 0) {
    if(http_ctime(&no_news_before, dateheader)) {
      buf_release(b);
      htsmsg_release(newsinfo);
      return;
    }

    htsmsg_add_u32(newsinfo, "nothingbefore", no_news_before);
    htsmsg_store_save(newsinfo, "sitenews");
    htsmsg_release(newsinfo);
  }

  htsmsg_t *doc = htsmsg_json_deserialize(buf_cstr(b));
  buf_release(b);
  if(doc == NULL) {
    return;
  }

  hts_mutex_lock(&news_mutex);

  htsmsg_t *news = htsmsg_get_list(doc, "news");
  if(news != NULL) {
    htsmsg_field_t *f;
    HTSMSG_FOREACH(f, news) {
      htsmsg_t *entry;
      if((entry = htsmsg_get_map_by_field(f)) == NULL)
        continue;

      const char *title = htsmsg_get_str(entry, "title");
      const char *created_on = htsmsg_get_str(entry, "created_on");
      int id = htsmsg_get_u32_or_default(entry, "id", 0);
      if(created_on == NULL || title == NULL || id == 0)
        continue;

      time_t t;

      if(parse_created_on_time(&t, created_on))
        continue;

      if(t < no_news_before)
        continue;

      char idstr[64];
      snprintf(idstr, sizeof(idstr), "sitenews:%d", id);
      prop_t *p = add_news_locked(idstr, title, NULL, "Read more", idstr);
      if(p != NULL) {
        prop_subscribe(PROP_SUB_TRACK_DESTROY,
                       PROP_TAG_CALLBACK, open_news, p,
                       PROP_TAG_ROOT, prop_create(p, "eventSink"),
                       PROP_TAG_MUTEX, &news_mutex,
                       NULL);
      }
    }
Ejemplo n.º 12
0
void cHTSPDemux::SubscriptionStart(htsmsg_t *m)
{
  htsmsg_t       *streams;
  htsmsg_field_t *f;
  if((streams = htsmsg_get_list(m, "streams")) == NULL)
  {
    XBMC->Log(LOG_ERROR, "%s - malformed message", __FUNCTION__);
    return;
  }

  m_Streams.iStreamCount = 0;

  HTSMSG_FOREACH(f, streams)
  {
    uint32_t    index;
    const char* type;
    htsmsg_t* sub;

    if (f->hmf_type != HMF_MAP)
      continue;

    sub = &f->hmf_msg;

    if ((type = htsmsg_get_str(sub, "type")) == NULL)
      continue;

    if (htsmsg_get_u32(sub, "index", &index))
      continue;

    const char *language = htsmsg_get_str(sub, "language");
    XBMC->Log(LOG_DEBUG, "%s - id: %d, type: %s, language: %s", __FUNCTION__, index, type, language);

    m_Streams.stream[m_Streams.iStreamCount].iFPSScale          = 0;
    m_Streams.stream[m_Streams.iStreamCount].iFPSRate           = 0;
    m_Streams.stream[m_Streams.iStreamCount].iHeight            = 0;
    m_Streams.stream[m_Streams.iStreamCount].iWidth             = 0;
    m_Streams.stream[m_Streams.iStreamCount].fAspect            = 0.0;

    m_Streams.stream[m_Streams.iStreamCount].iChannels          = 0;
    m_Streams.stream[m_Streams.iStreamCount].iSampleRate        = 0;
    m_Streams.stream[m_Streams.iStreamCount].iBlockAlign        = 0;
    m_Streams.stream[m_Streams.iStreamCount].iBitRate           = 0;
    m_Streams.stream[m_Streams.iStreamCount].iBitsPerSample     = 0;

    m_Streams.stream[m_Streams.iStreamCount].strLanguage[0] = 0;
    m_Streams.stream[m_Streams.iStreamCount].strLanguage[1] = 0;
    m_Streams.stream[m_Streams.iStreamCount].strLanguage[2] = 0;
    m_Streams.stream[m_Streams.iStreamCount].strLanguage[3] = 0;

    m_Streams.stream[m_Streams.iStreamCount].iIdentifier      = -1;

    if(!strcmp(type, "AC3"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_AUDIO;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_AC3;
      SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "EAC3"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_AUDIO;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_EAC3;
      SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "MPEG2AUDIO"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_AUDIO;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_MP2;
      SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "AAC"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_AUDIO;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_AAC;
      SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "MPEG2VIDEO"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_VIDEO;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_MPEG2VIDEO;
      m_Streams.stream[m_Streams.iStreamCount].iWidth           = htsmsg_get_u32_or_default(sub, "width" , 0);
      m_Streams.stream[m_Streams.iStreamCount].iHeight          = htsmsg_get_u32_or_default(sub, "height" , 0);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "H264"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_VIDEO;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_H264;
      m_Streams.stream[m_Streams.iStreamCount].iWidth           = htsmsg_get_u32_or_default(sub, "width" , 0);
      m_Streams.stream[m_Streams.iStreamCount].iHeight          = htsmsg_get_u32_or_default(sub, "height" , 0);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "DVBSUB"))
    {
      uint32_t composition_id = 0, ancillary_id = 0;
      htsmsg_get_u32(sub, "composition_id", &composition_id);
      htsmsg_get_u32(sub, "ancillary_id"  , &ancillary_id);

      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_SUBTITLE;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_DVB_SUBTITLE;
      SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage);
      m_Streams.stream[m_Streams.iStreamCount].iIdentifier      = (composition_id & 0xffff) | ((ancillary_id & 0xffff) << 16);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "TEXTSUB"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_SUBTITLE;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_TEXT;
      SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage);
      m_Streams.iStreamCount++;
    }
    else if(!strcmp(type, "TELETEXT"))
    {
      m_Streams.stream[m_Streams.iStreamCount].iStreamIndex     = m_Streams.iStreamCount;
      m_Streams.stream[m_Streams.iStreamCount].iPhysicalId      = index;
      m_Streams.stream[m_Streams.iStreamCount].iCodecType       = CODEC_TYPE_SUBTITLE;
      m_Streams.stream[m_Streams.iStreamCount].iCodecId         = CODEC_ID_DVB_TELETEXT;
      m_Streams.iStreamCount++;
    }

    if (m_Streams.iStreamCount >= PVR_STREAM_MAX_STREAMS)
    {
      XBMC->Log(LOG_ERROR, "%s - max amount of streams reached", __FUNCTION__);
      break;
    }
  }
Ejemplo n.º 13
0
static int
http_markdown_class(http_connection_t *hc, const char *clazz)
{
  const idclass_t *ic;
  const char *lang = hc->hc_access->aa_lang_ui;
  htsbuf_queue_t *hq = &hc->hc_reply;
  htsmsg_t *m, *l, *n, *e, *x;
  htsmsg_field_t *f, *f2;
  const char *s, **doc;
  int nl = 0, first = 1;

  pthread_mutex_lock(&global_lock);
  ic = idclass_find(clazz);
  if (ic == NULL) {
    pthread_mutex_unlock(&global_lock);
    return HTTP_STATUS_NOT_FOUND;
  }
  doc = ic->ic_doc;
  m = idclass_serialize(ic, lang);
  pthread_mutex_unlock(&global_lock);
  s = htsmsg_get_str(m, "caption");
  if (s) {
    md_header(hq, "##", s);
    nl = md_nl(hq, 1);
  }
  if (doc) {
    for (; *doc; doc++) {
      if (*doc[0] == '\xff') {
        htsbuf_append_str(hq, tvh_gettext_lang(lang, *doc + 1));
      } else {
        htsbuf_append_str(hq, *doc);
      }
    }
  }
  l = htsmsg_get_list(m, "props");
  HTSMSG_FOREACH(f, l) {
    n = htsmsg_field_get_map(f);
    if (!n) continue;
    s = htsmsg_get_str(n, "caption");
    if (!s) continue;
    if (first) {
      nl = md_nl(hq, nl);
      htsbuf_append_str(hq, "####");
      htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("Items")));
      md_nl(hq, 1);
      md_nl(hq, 1);
      htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("The items have the following functions:")));
      md_nl(hq, 1);
      first = 0;
    }
    nl = md_nl(hq, nl);
    md_style(hq, "**", s);
    md_nl(hq, 1);
    s = htsmsg_get_str(n, "description");
    if (s) {
      md_text(hq, ": ", "  ", s);
      md_nl(hq, 1);
    }
    e = htsmsg_get_list(n, "enum");
    if (e) {
      HTSMSG_FOREACH(f2, e) {
        x = htsmsg_field_get_map(f2);
        if (x) {
          s = htsmsg_get_str(x, "val");
        } else {
          s = htsmsg_field_get_string(f2);
        }
        if (s) {
          md_nl(hq, 1);
          htsbuf_append(hq, "  * ", 4);
          md_style(hq, "**", s);
        }
      }
      md_nl(hq, 1);
    }
Ejemplo n.º 14
0
static void
check_upgrade(int set_news)
{
  char url[1024];
  char *result;
  htsmsg_t *json;
  char errbuf[1024];

  if(inhibit_checks)
    return;

  if(upgrade_track == NULL) {
    prop_set_string(upgrade_error, "No release track specified");
    goto err;
  }

  prop_set_string(upgrade_status, "checking");

  TRACE(TRACE_DEBUG, "Upgrade", "Checking upgrades for %s-%s",
	upgrade_track, archname);

  snprintf(url, sizeof(url), "%s/%s-%s.json", ctrlbase, upgrade_track,
	   archname);

  result = fa_load(url, NULL, NULL, errbuf, sizeof(errbuf),
		   NULL, 0, NULL, NULL);
  if(result == NULL) {
    prop_set_string(upgrade_error, errbuf);
  err:
    prop_set_string(upgrade_status, "checkError");
    return;
  }
  
  json = htsmsg_json_deserialize(result);
  free(result);

  if(json == NULL) {
    prop_set_string(upgrade_error, "Malformed JSON in repository");
    goto err;
  }

  // Find an artifact for us

  const char *dlurl = NULL;
  const char *sha1 = NULL;
  int dlsize = 0;
  const char *ver;

  htsmsg_t *artifacts = htsmsg_get_list(json, "artifacts");
  if(artifacts != NULL) {
    htsmsg_field_t *f;
    HTSMSG_FOREACH(f, artifacts) {
      htsmsg_t *a;
      if((a = htsmsg_get_map_by_field(f)) == NULL)
	continue;

      const char *type = htsmsg_get_str(a, "type");

      if(type == NULL || strcmp(artifact_type, type))
	continue;

      dlurl = htsmsg_get_str(a, "url");
      sha1 = htsmsg_get_str(a, "sha1");
      dlsize = htsmsg_get_u32_or_default(a, "size", 0);
      break;
    }
Ejemplo n.º 15
0
Archivo: cfg.c Proyecto: yfqian/libsvc
cfg_t *
cfg_get_list(cfg_t *c, const char *id)
{
  return htsmsg_get_list(c, id);
}
Ejemplo n.º 16
0
static void
iptv_auto_network_process_m3u_item(iptv_network_t *in,
                                   const char *last_url,
                                   const http_arg_list_t *remove_args,
                                   int64_t chnum, htsmsg_t *item,
                                   int *total, int *count)
{
  htsmsg_t *conf;
  htsmsg_field_t *f;
  mpegts_mux_t *mm;
  iptv_mux_t *im;
  url_t u;
  int change, epgcfg;
  http_arg_list_t args;
  http_arg_t *ra1, *ra2, *ra2_next;
  htsbuf_queue_t q;
  size_t l;
  int64_t chnum2;
  const char *url, *name, *logo, *epgid, *tags;
  char url2[512], custom[512], name2[128], buf[32], *n;

  url = htsmsg_get_str(item, "m3u-url");

  if (url == NULL ||
      (strncmp(url, "file://", 7) &&
       strncmp(url, "pipe://", 7) &&
       strncmp(url, "http://", 7) &&
       strncmp(url, "https://", 8) &&
       strncmp(url, "rtsp://", 7) &&
       strncmp(url, "rtsps://", 8) &&
       strncmp(url, "udp://", 6) &&
       strncmp(url, "rtp://", 6)))
    return;

  epgid = htsmsg_get_str(item, "tvh-chnum");
  chnum2 = epgid ? prop_intsplit_from_str(epgid, CHANNEL_SPLIT) : 0;
  if (chnum2 > 0) {
    chnum += chnum2;
  } else if (chnum) {
    if (chnum % CHANNEL_SPLIT)
      chnum += *total;
    else
      chnum += (int64_t)*total * CHANNEL_SPLIT;
  }

  name = htsmsg_get_str(item, "m3u-name");
  if (name == NULL)
    name = "";

  logo = htsmsg_get_str(item, "tvg-logo");
  if (logo == NULL)
    logo = htsmsg_get_str(item, "logo");

  epgid = htsmsg_get_str(item, "tvg-id");
  epgcfg = _epgcfg_from_str(htsmsg_get_str(item, "tvh-epg"));
  tags = htsmsg_get_str(item, "tvh-tags");
  if (!tags) tags = htsmsg_get_str(item, "group-title");
  if (tags) {
    tags = n = strdupa(tags);
    while (*n) {
      if (*n == '|')
        *n = '\n';
      n++;
    }
  }

  urlinit(&u);
  custom[0] = '\0';

  if (strncmp(url, "pipe://", 7) == 0)
    goto skip_url;

  if (strncmp(url, "http://", 7) == 0 ||
      strncmp(url, "https://", 8) == 0) {
    conf = htsmsg_get_list(item, "m3u-http-headers");
    if (conf) {
      l = 0;
      HTSMSG_FOREACH(f, conf)
        if ((n = (char *)htsmsg_field_get_str(f)) != NULL)
          tvh_strlcatf(custom, sizeof(custom), l, "%s\n", n);
    }
  }
Ejemplo n.º 17
0
static int
http_github(http_connection_t *hc, const char *remain, void *opaque)
{
  const char *pid = http_arg_get(&hc->hc_req_args, "project");
  const char *key = http_arg_get(&hc->hc_req_args, "key");


  if(pid == NULL) {
    trace(LOG_WARNING, "github: Missing 'project' in request");
    return 400;
  }

  if(key == NULL) {
    trace(LOG_WARNING, "github: Missing 'key' in request");
    return 400;
  }

  project_cfg(pc, pid);
  if(pc == NULL) {
    trace(LOG_DEBUG, "github: Project '%s' not configured", pid);
    return 404;
  }

  const char *mykey = cfg_get_str(pc, CFG("github", "key"), "");

  if(strcmp(mykey, key)) {
    trace(LOG_WARNING, "github: Invalid key received (%s) for project %s",
          key, pid);
    return 403;
  }

  project_t *p = project_get(pid);

  const char *json = http_arg_get(&hc->hc_req_args, "payload");
  if(json == NULL) {
    plog(p, "github", "github: Missing payload in request");
    return 400;
  }

  char errbuf[256];
  htsmsg_t *msg = htsmsg_json_deserialize(json, errbuf, sizeof(errbuf));
  if(msg == NULL) {
    plog(p, "github", "github: Malformed JSON in github request -- %s",
         errbuf);
    return 400;
  }

  const char *ref = htsmsg_get_str(msg, "ref");
  if(ref != NULL && !strncmp(ref, "refs/heads/", strlen("refs/heads/")))
    ref += strlen("refs/heads/");

  htsmsg_t *list = htsmsg_get_list(msg, "commits");
  if(ref != NULL && list != NULL) {
    htsmsg_field_t *f;
    HTSMSG_FOREACH(f, list) {
      htsmsg_t *c = htsmsg_get_map_by_field(f);
      if(c == NULL)
        continue;

      const char *url = htsmsg_get_str(c, "url");
      const char *msg = htsmsg_get_str(c, "message");
      htsmsg_t *a = htsmsg_get_map(c, "author");
      const char *author = a ? htsmsg_get_str(a, "name") : NULL;

      int added    = count_list(c, "added");
      int removed  = count_list(c, "removed");
      int modified = count_list(c, "modified");

      int len;
      char buf[512];
      char ctx[128];

      url = url ? urlshorten(url) : NULL;

      snprintf(ctx, sizeof(ctx), "changes/%s", ref);

      len = snprintf(buf, sizeof(buf),
                     "Commit in '"COLOR_BLUE"%s"COLOR_OFF"' by "COLOR_PURPLE"%s"COLOR_OFF" [",
                     ref, author ?: "???");

      if(added)
        len += snprintf(buf + len, sizeof(buf) - len,
                        COLOR_GREEN "%d file%s added",
                        added, added == 1 ? "" : "s");

      if(modified)
        len += snprintf(buf + len, sizeof(buf) - len,
                        COLOR_YELLOW "%s%d file%s modified",
                        added ? ", "  : "",
                        modified, modified == 1 ? "" : "s");

      if(removed)
        len += snprintf(buf + len, sizeof(buf) - len,
                        COLOR_RED "%s%d file%s removed",
                        added || modified ? ", "  : "",
                        removed, removed == 1 ? "" : "s");

      snprintf(buf + len, sizeof(buf) - len, COLOR_OFF"]%s%s",
               url ? " " : "", url ?: "");

      plog(p, ctx, "%s", buf);
      plog(p, ctx, "%s", msg);
    }