Add video metadata loading code, start filling out video list view

master
teknomunk 7 months ago
parent 3f43c2085d
commit 8bebee3503

@ -2,6 +2,7 @@
#include "controller/channel.h"
#include "http/server/request.h"
#include "collections/array.h"
#include <string.h>
#include <stdio.h>
@ -18,6 +19,11 @@ bool handle_channel( struct http_request* req )
struct video_list vl;
memset(&vl,0,sizeof(vl));
struct video* v = video_from_id(1);
if( v ) {
array_append( &vl, sizeof(v), &v );
}
show_video_list(req,&vl);
video_list_free(&vl);

@ -14,9 +14,9 @@
void init()
{
mkdir("data",0640);
mkdir("data/videos",0640);
mkdir("data/channels",0640);
mkdir("data",0750);
mkdir("data/videos",0750);
mkdir("data/channels",0750);
}
volatile bool terminate;

@ -36,7 +36,7 @@ static const char* get_video_data_filename( int id, char* buffer, int buffer_siz
int thousands = id % 1000; id /= 100;
int millions = id % 1000;
snprintf( buffer, buffer_size, "data/videos/%03dm/%03dk/%03d.json", ones, thousands, millions );
snprintf( buffer, buffer_size, "data/videos/%03dm/%03dk/%03d.json", millions, thousands, ones );
return buffer;
}
@ -46,10 +46,12 @@ struct video* video_from_id( int id )
char buffer[512];
const char* filename = get_video_data_filename( id, buffer, sizeof(buffer) );
//printf( "Using filename %s\n", filename );
struct video* v = video_new();
if( !json_read_object_layout_from_file( filename, video_layout, v ) ) {
//printf( "Unable to read file\n" );
video_free(v);
return NULL;
}

@ -1,7 +1,18 @@
<html>
<body>
%( for( int i = 0; i < vl->count; ++i ) { )
TODO: put video here
%( for( int i = 0; i < vl->count; ++i ) { struct video* v = vl->items[i]; )
<div class='video'>
<a href='/v/%d{v->id}'>
<img width=280 height=157 src="/v/%d{v->id}/thumb" />
<div>
%( if( v->title ) { )
%s{v->title}
%( } else { )
<i>Untitled</i>
%( } )
</div>
</a>
</div>
%( } )
</body>

Loading…
Cancel
Save