Beispiel #1
0
static void
add_item(bmdb_t *b, const char *url, const char *parent, rstr_t *contenttype,
         const char *title, int track, const char *artist, int duration)
{
    prop_t *c = prop_create_r(b->b_nodes, url);

    prop_unmark(c);

    prop_set(c, "type", PROP_SET_RSTRING, contenttype);
    prop_set(c, "url", PROP_SET_STRING, url);

    prop_t *metadata = prop_create_r(c, "metadata");

    if(track)
        prop_set(metadata, "track", PROP_SET_INT, track);

    if(artist)
        prop_set(metadata, "artist", PROP_SET_STRING, artist);

    if(duration > 0)
        prop_set(metadata, "duration", PROP_SET_INT, duration / 1000);

    if(title == NULL) {
        char fname[512];
        fa_url_get_last_component(fname, sizeof(fname), url);

        rstr_t *ft = metadata_remove_postfix(fname);
        prop_set(metadata, "title", PROP_SET_RSTRING, ft);
        rstr_release(ft);
    } else {
        prop_set(metadata, "title", PROP_SET_STRING, title);
    }


#if 0
    prop_t *options = prop_create(bi->bi_prop, "options");
    metadata_bind_video_info(metadata, bi->bi_url, title, NULL, 0, options,
                             bi->bi_prop, NULL, 0, 1);
#endif
    prop_ref_dec(metadata);
    prop_ref_dec(c);
}
Beispiel #2
0
static JSBool 
js_item_bindVideoMetadata(JSContext *cx, JSObject *obj,
			  uintN argc, jsval *argv, jsval *rval)
{
  js_item_t *ji = JS_GetPrivate(cx, obj);
  JSObject *o = NULL;
  rstr_t *title;
  if(!JS_ConvertArguments(cx, argc, argv, "o", &o))
    return JS_FALSE;
  
  rstr_t *filename = js_prop_rstr(cx, o, "filename");
  int year         = js_prop_int_or_default(cx, o, "year", 0);

  if(filename != NULL) {
    // Raw filename case
    title = metadata_remove_postfix_rstr(filename);
    rstr_release(filename);
    year = -1;
  } else {
    title = js_prop_rstr(cx, o, "title");
  }

  int season    = js_prop_int_or_default(cx, o, "season", -1);
  int episode   = js_prop_int_or_default(cx, o, "episode", -1);
  rstr_t *imdb  = js_prop_rstr(cx, o, "imdb");
  int duration  = js_prop_int_or_default(cx, o, "duration", 0);

  if(ji->ji_mlv != NULL)
    mlv_unbind(ji->ji_mlv, 0);

  ji->ji_mlv =
    metadata_bind_video_info(ji->ji_url, title, imdb, duration,
			     ji->ji_root, NULL, 0, 0, year, season, episode,
                             0);
  rstr_release(imdb);
  rstr_release(title);
  
  *rval = JSVAL_VOID;
  return JS_TRUE;
}