-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathYoutubeSearch.cs
64 lines (50 loc) · 1.61 KB
/
YoutubeSearch.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System.Threading.Tasks;
using MikuBot.Commands;
using MikuBot.ExtraPlugins.Helpers;
using MikuBot.Helpers;
using MikuBot.Modules;
namespace MikuBot.ExtraPlugins
{
/*public class YoutubeSearch : MsgCommandModuleBase {
private void Search(Receiver receiver, string queryString) {
var request = YoutubeUtils.YouTubeRequest;
var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
query.OrderBy = "relevance";
query.Query = queryString;
query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
var videoFeed = request.Get<Video>(query);
if (!videoFeed.Entries.Any()) {
receiver.Msg("Youtube: no results.");
return;
}
var first = videoFeed.Entries.First();
receiver.Msg(string.Format("Youtube: http://youtu.be/{0} - {1}", first.VideoId, YoutubeUtils.Format(first)));
}
public override void HandleCommand(MsgCommand cmd, IBotContext bot) {
if (!CheckCall(cmd, bot))
return;
var query = cmd.BotCommand.CommandString;
var receiver = new Receiver(bot.Writer, cmd.ChannelOrSenderNick);
Task.Factory.StartNew(() => Search(receiver, query))
.ContinueWith(TaskHelper.HandleTaskException, TaskContinuationOptions.OnlyOnFaulted);
}
public override int CooldownChannelMs {
get { return 3000; }
}
public override int CooldownUserMs {
get { return 10000; }
}
public override string HelpText {
get { return "Searches for Youtube for a video."; }
}
public override bool IsPassive {
get { return true; }
}
public override string Name {
get { return "Yt"; }
}
public override string UsageHelp {
get { return "yt <search query>"; }
}
}*/
}