~ghuter/caoydl

5e620cd9868239347a51e669f0e4f96e3dda8be0 — ghuter 1 year, 10 months ago 608f7d1
create an uri scheme, "yt://", to prefix youtube IDs
3 files changed, 14 insertions(+), 6 deletions(-)

M caoydl.c
M youtube.c
M youtube.h
M caoydl.c => caoydl.c +5 -5
@@ 86,7 86,7 @@ render(struct Items *r, char ext_search)
	if (!ext_search) {
		for (i = 0; i < r->nitem; i++) {
			if (item[i].id[0] && item[i].title[0]) {
	                        OUTESCAPE(item[i].id);
	                        OUT("%s%s", urischeme, item[i].id);
				OUT("\t");
				OUTESCAPE(item[i].title);
				OUT("\n");


@@ 118,7 118,7 @@ render(struct Items *r, char ext_search)

		if (item[i].id[0]) {
			OUT("URL:           https://www.youtube.com/embed/");
                        OUTESCAPE(item[i].id);
			OUT("%s", item[i].id);
			OUT("\n");
		}



@@ 203,7 203,7 @@ render_chan_urls(struct Items *r)
	for (i = 0; i < r->nitem; i++) {
		if (vid[i].title[0] &&
		    vid[i].id[0]) {
			OUTESCAPE(vid[i].id);
			OUT("%s%s", urischeme, vid[i].id);
			OUT("\t");
			OUTESCAPE(vid[i].title);
			OUT("\n");


@@ 226,7 226,7 @@ render_chan_pl(struct Items *r)
		if (vid[i].title[0]
		    && vid[i].vid_count[0]
		    && vid[i].id[0]) {
			OUTESCAPE(vid[i].id);
			OUT("%s%s", urischeme, vid[i].id);
			OUT("\t");
			OUTESCAPE(vid[i].vid_count);
			OUT("\t");


@@ 250,7 250,7 @@ render_playlist_urls(struct Items *r)
	for (i = 0; i < r->nitem; i++) {
		if (vid[i].title[0] &&
		    vid[i].id[0]) {
			OUTESCAPE(vid[i].id);
			OUT("%s%s", urischeme, vid[i].id);
			OUT("\t");
			OUTESCAPE(vid[i].title);
			OUT("\n");

M youtube.c => youtube.c +7 -1
@@ 54,7 54,6 @@ idchr(const unsigned char c)
struct Id
url2id(char *url)
{
	size_t len = strlen(url);
	struct Id id = {};

	struct Url2id {


@@ 70,6 69,13 @@ url2id(char *url)
		{ STRANDLEN("list="),    Playlist, 34, },
	};

	/* if our particular uri scheme is in use, skip it */
	char *s = strstr(url, urischeme);
	if (s)
		url = s + strlen(urischeme);

	size_t len = strlen(url);

	switch (len) {
	case 11:
		id.type = Video;

M youtube.h => youtube.h +2 -0
@@ 1,6 1,8 @@
#define MAX_VIDEOS 500
#define MAX_URLS 30

static char urischeme[] = "yt://";

enum {
	PL,
	CHAN_VIDS,