Esempio n. 1
0
        internal async Task <int> SendToQueue(YoutubeInfo info)
        {
            using (var ms = new MemoryStream())
                using (var writer = new BsonWriter(ms))
                {
                    var serializer = new JsonSerializer();
                    serializer.Serialize(writer, info, typeof(YoutubeInfo));
                    Debug.WriteLine("Sending to Queue: {0}", Convert.ToBase64String(ms.ToArray()));
                    byte[] response = await tcpConnector.SendData(ms.ToArray(), serverAddress);

                    return(BitConverter.ToInt32(response, 0));
                }
        }
Esempio n. 2
0
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    IEnumerator GetYoutubeCount()
    {
        string json_url = string.Format("https://www.googleapis.com/youtube/v3/channels?part=statistics&id={0}&key={1}", ChannelID, YoutubeKey);
        WWW    w        = new WWW(json_url);

        yield return(w);

        if (w.error == null)
        {
            //Debug.Log("Youtube: " + w.text);
            //get value from json deserialize
            YouTube = YoutubeInfo.CreateFromJSON(w.text);
            foreach (bl_SocialCounterDisplay d in YoutubeDisplay)
            {
                d.SendCount(YoutubeSuscribers());
            }
        }
        else
        {
            Debug.LogWarning("Error: " + w.error);
        }
    }
Esempio n. 3
0
        public List <YoutubeInfo> LoadVideosKey(string keyWord)
        {
            var searchListRequest = youtubeService.Search.List("snippet");

            searchListRequest.Q          = keyWord; // Replace with your search term.
            searchListRequest.MaxResults = 20;

            // Call the search.list method to retrieve results matching the specified query term.

            //TRY!!! - przy braku neta się sypie
            var searchListResponse = searchListRequest.Execute();

            List <string> videos = new List <string>();
            //List<string> channels = new List<string>();
            //List<string> playlists = new List<string>();

            List <YoutubeInfo> resultInfo = new List <YoutubeInfo>();

            foreach (var ytInfo in searchListResponse.Items)
            {
                YoutubeInfo result = new YoutubeInfo();
                switch (ytInfo.Id.Kind)
                {
                case "youtube#video":
                    videos.Add(String.Format("{0} ({1})", ytInfo.Snippet.Title, ytInfo.Id.VideoId));
                    result.title       = ytInfo.Snippet.Title;
                    result.channelName = ytInfo.Snippet.ChannelTitle;
                    result.id          = ytInfo.Id.VideoId;
                    //result.LinkUrl = "http://www.youtube.com/embed/" + ytInfo.Id.VideoId;
                    if (ytInfo.Snippet.Thumbnails.High != null)
                    {
                        result.thumbnail = ytInfo.Snippet.Thumbnails.High;
                    }
                    else if (ytInfo.Snippet.Thumbnails.Medium != null)
                    {
                        result.thumbnail = ytInfo.Snippet.Thumbnails.Medium;
                    }
                    else if (ytInfo.Snippet.Thumbnails.Standard != null)
                    {
                        result.thumbnail = ytInfo.Snippet.Thumbnails.Standard;
                    }
                    else if (ytInfo.Snippet.Thumbnails.Default__ != null)
                    {
                        result.thumbnail = ytInfo.Snippet.Thumbnails.Default__;
                    }
                    resultInfo.Add(result);
                    break;

                case "youtube#channel":
                    //channels.Add(String.Format("{0} ({1})", MusicPiece.Snippet.Title, MusicPiece.Id.ChannelId));
                    //result.ChannelName = MusicPiece.Snippet.Title;
                    break;

                case "youtube#playlist":
                    //playlists.Add(String.Format("{0} ({1})", MusicPiece.Snippet.Title, MusicPiece.Id.PlaylistId));
                    //result.Title = MusicPiece.Snippet.Title;
                    break;
                }
                //resultInfo.Add(result);
            }
            return(resultInfo);
        }