$ git clone http://tcclient.ion.nu/tc_client.git
commit 502e92ee63a89a296f18052fc0e8f7f5bee241e0
Author: Alicia <...>
Date: Mon Aug 10 03:25:04 2015 +0200
modbot: added support for youtube links with time offsets.
diff --git a/ChangeLog b/ChangeLog
index 30a159e..bcf65cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@ tc_client-gtk: changed how pane handles are set to be wide to be compatible with
tc_client-gtk: flush logs after every write to avoid loss of data.
irchack: added support for captchas.
cursedchat: added support for captchas.
+modbot: added support for youtube links with time offsets.
0.34:
Fixed memory alignment in rtmp/amf code (for CPU architectures that are picky about it)
Print version info when called with -v/--version (contributed by Jade)
diff --git a/utilities/modbot/modbot.c b/utilities/modbot/modbot.c
index 01da835..6097bec 100644
--- a/utilities/modbot/modbot.c
+++ b/utilities/modbot/modbot.c
@@ -143,7 +143,7 @@ void playnextvid()
playing=queue.items[0].video;
requester=queue.items[0].requester;
title=queue.items[0].title;
- say(0, "/mbs youTube %s 0 %s\n", playing, queue.items[0].title);
+ say(0, "/mbs youTube %s %u %s\n", playing, queue.items[0].timeoffset, queue.items[0].title);
--queue.itemcount;
memmove(queue.items, &queue.items[1], sizeof(struct queueitem)*queue.itemcount);
// Find out the video's length and schedule an alarm for then
@@ -370,6 +370,24 @@ int main(int argc, char** argv)
char title[256];
char vid[1024];
char viderr[1024];
+ unsigned int timeoffset=0;
+ char* timestr=strstr(&msg[9], "&t=");
+ if(!timestr){timestr=strstr(&msg[9], "?t=");}
+ if(timestr)
+ {
+ timestr=×tr[3];
+ while(timestr[0])
+ {
+ unsigned int num=strtoul(timestr, ×tr, 10);
+ if(timestr[0])
+ {
+ if(timestr[0]=='h'){num*=3600;}
+ else if(timestr[0]=='m'){num*=60;}
+ timestr=×tr[1];
+ }
+ timeoffset+=num;
+ }
+ }
getvidinfo(&msg[9], "--get-id", vid, viderr, 1024);
if(!vid[0]) // Nothing found
{
@@ -409,7 +427,7 @@ int main(int argc, char** argv)
list_save(&badvids, "badvids.txt");
}
- queue_add(&queue, vid, nick, title);
+ queue_add(&queue, vid, nick, title, timeoffset);
if(!list_contains(&goodvids, vid))
{
if(plist)
diff --git a/utilities/modbot/queue.c b/utilities/modbot/queue.c
index 1583e2b..58ec585 100644
--- a/utilities/modbot/queue.c
+++ b/utilities/modbot/queue.c
@@ -41,7 +41,7 @@ void queue_del(struct queue* queue, const char* item)
}
}
-void queue_add(struct queue* queue, const char* item, const char* requester, const char* title)
+void queue_add(struct queue* queue, const char* item, const char* requester, const char* title, unsigned int timeoffset)
{
queue_del(queue, item);
unsigned int len;
@@ -54,6 +54,7 @@ void queue_add(struct queue* queue, const char* item, const char* requester, con
queue->items[queue->itemcount-1].video=strndup(item, len);
queue->items[queue->itemcount-1].requester=strdup(requester);
queue->items[queue->itemcount-1].title=strdup(title);
+ queue->items[queue->itemcount-1].timeoffset=timeoffset*1000;
item=&item[len];
}
}
diff --git a/utilities/modbot/queue.h b/utilities/modbot/queue.h
index 0fa1370..98bf951 100644
--- a/utilities/modbot/queue.h
+++ b/utilities/modbot/queue.h
@@ -19,6 +19,7 @@ struct queueitem
char* video;
char* requester;
char* title;
+ unsigned int timeoffset;
};
struct queue
@@ -28,6 +29,6 @@ struct queue
};
extern void queue_del(struct queue* queue, const char* item);
-extern void queue_add(struct queue* queue, const char* item, const char* requester, const char* title);
+extern void queue_add(struct queue* queue, const char* item, const char* requester, const char* title, unsigned int timeoffset);
extern int queue_getpos(struct queue* queue, char* item);
extern void queue_movetofront(struct queue* queue, unsigned int pos);