public StreamingService(BotService bot, RocksmithService rocksmith) { // Бот Bot = bot; Rocksmith = rocksmith; // Настройки приложения JObject settings = JsonCommon.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json")); contentProviders = new List <ContentProvider>(); Broadcast = new Broadcast(); JToken streamingConfigs = settings["streaming"]; if (!streamingConfigs.IsNullOrEmpty()) { if (!streamingConfigs["twitch"].IsNullOrEmpty()) { Twitch = new TwitchConnector(Bot, JsonConvert.DeserializeObject <TwitchConnectorConfig>(streamingConfigs["twitch"].ToString())); } if (!streamingConfigs["youtube"].IsNullOrEmpty()) { Youtube = new YoutubeConnector(Bot, JsonConvert.DeserializeObject <YoutubeConnectorConfig>(streamingConfigs["youtube"].ToString())); } } InitProviders((JObject)settings["providers"]); InitWidgetsSchemes(settings["scheme"].ToString()); InitBroadcastHandlers(); }
private StandardVideos GetVideosForStandard(string code) { var res = new StandardVideos { StandardName = code, Videos = YoutubeConnector.Search(code, 20).ToList() }; return(res); }
public ActionResult Preview(string id, int announcementApplicationId) { var storage = new Storage(); storage.Set(announcementApplicationId.ToString(), id); var connector = new YoutubeConnector(); var video = connector.GetById(id); var model = VideoModel.Create(video); model.AnnouncementApplicationId = announcementApplicationId; return(View("Preview", model)); }
public async Task <ActionResult> Attach(string id, int announcementApplicationId) { var video = YoutubeConnector.GetById(id); await ChalkableConnector.Announcement.UpdateAnnouncementApplicationMeta(announcementApplicationId, video.ShortTitle, video.ThumbUrl, video.ShortDescription); var storage = new Storage(ChalkableAuthorization.Configuration.ConnectionString); storage.Set(CurrentUser.DistrictId, announcementApplicationId, video.Id); return(ChlkJson(true)); }
public ActionResult Edit(string query, int announcementApplicationId) { var model = new SearchModel(); model.Query = query; if (string.IsNullOrEmpty(query)) { var chalkableConnector = new ChalkableConnector(OauthClient); var anap = chalkableConnector.GetAnnouncementApplicationById(announcementApplicationId); var ann = chalkableConnector.GetAnnouncemnetById(anap.data.announcementid); query = [email protected]; } var connector = new YoutubeConnector(); var videos = connector.Search(query); model.Videos = videos.Select(VideoModel.Create); model.AnnouncementApplicationId = announcementApplicationId; return(View("Edit", model)); }
protected override PaginatedList <ApplicationContent> GetApplicationContents(IList <StandardInfo> standardInfos, int?start, int?count) { count = count ?? 5; start = start ?? 0; var ids = standardInfos.Select(x => x.StandardId).JoinString(","); var chlkConnector = new ChalkableConnector(ChalkableAuthorization); var youtubeConnector = new YoutubeConnector(); var standards = YoutubeController.GetStandardCodes(ids, chlkConnector); var videos = standards.SelectMany(x => youtubeConnector.Search(x, 5)) .Select(x => new ApplicationContent { ContentId = x.Id, Description = x.ShortDescription, ImageUrl = x.ThumbUrl, Text = x.ShortTitle }).ToList(); return(new PaginatedList <ApplicationContent>(videos.Take(count.Value), videos.Count)); }
public ActionResult Video(string id) { var video = YoutubeConnector.GetById(id); return(ChlkJson(video)); }
public ActionResult SearchVideos(string searchQuery) { var videos = YoutubeConnector.Search(searchQuery); return(ChlkJson(videos)); }