$ git clone http://tcclient.ion.nu/tc_client.git
commit 246f003bb142aadc8f59c74908a798dfa75b9832
Author: Alicia <...>
Date: Sun Apr 3 16:16:51 2016 +0200
modbot: only use youtube-dl's 'ytsearch:' for --get-id, and only if it doesn't appear to be an ID already.
diff --git a/ChangeLog b/ChangeLog
index 9dc8dcc..26fd078 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+0.39:
+modbot: only use youtube-dl's 'ytsearch:' for --get-id, and only if it doesn't appear to be an ID already.
0.38:
Handle multi-line messages.
Added option --hexcolors to print hex color codes instead of ANSI color escape codes.
diff --git a/Makefile b/Makefile
index 502cbc4..4814784 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.38
+VERSION=0.39pre
CFLAGS=-g3 -Wall $(shell curl-config --cflags)
LDFLAGS=-g3
PREFIX=/usr/local
diff --git a/utilities/modbot/modbot.c b/utilities/modbot/modbot.c
index c0e52ee..550ed54 100644
--- a/utilities/modbot/modbot.c
+++ b/utilities/modbot/modbot.c
@@ -111,6 +111,22 @@ void getvidinfo(const char* vid, const char* type, char* buf, char* errbuf, unsi
{
int out[2];
int err[2];
+ char search[strlen("ytsearch:0")+strlen(vid)];
+ if(!strcmp(type, "--get-id"))
+ {
+ char lookslikeid=(strlen(vid)==11);
+ const char* ch=vid;
+ while(lookslikeid && ch[0])
+ {
+ if(!isalnum(ch[0]) && ch[0]!='-' && ch[0]!='_'){lookslikeid=0;}
+ ch=&ch[1];
+ }
+ if(!lookslikeid)
+ {
+ sprintf(search, "ytsearch:%s", vid);
+ vid=search;
+ }
+ }
unsigned int tries=3;
while(tries)
{
@@ -122,9 +138,7 @@ void getvidinfo(const char* vid, const char* type, char* buf, char* errbuf, unsi
close(err[0]);
dup2(out[1], 1);
dup2(err[1], 2);
- char search[strlen("ytsearch:0")+strlen(vid)];
- sprintf(search, "ytsearch:%s", vid);
- execlp("youtube-dl", "youtube-dl", type, "--", search, (char*)0);
+ execlp("youtube-dl", "youtube-dl", type, "--", vid, (char*)0);
perror("execlp(youtube-dl)");
_exit(1);
}