예제 #1
0
        public async Task <IEnumerable <ITweet> > FetchHomeTimeline(long?sinceid = null, long?maxid = null, int?num = 100)
        {
            var result = await Tokens.Statuses.HomeTimelineAsync(since_id => sinceid, max_id => maxid, count => num);

            var tweets = result.Select(status =>
            {
                var tweet = TweetFactory.Create(status);

                var entities = status.ExtendedEntities ?? status.Entities;
                if (entities?.Media == null)
                {
                    return(tweet);
                }

                var photos = entities.Media
                             .Where(media => media.Type == "photo")
                             .Select(media => new TweetImage(media.MediaUrl));

                //var videos = status.Entities.Media
                //		.Where(media => media.Type == "animated_gif" || media.Type == "video")
                //		.SelectMany(
                //			media => media?.VideoInfo?.Variants
                //				.Select(video => video.Url))
                //				.Where(url => System.IO.Path.GetExtension(url) == ".mp4");

                //tweet.MediaURLs = photos.Concat(videos);
                tweet.Medias = photos;

                return(tweet);
            });

            return(tweets);
        }
예제 #2
0
        public async Task <IEnumerable <ITweet> > Search(string keyword, long?maxid = null, int num = 15)
        {
            Debug.WriteLine("searchTweet Start : Keyword={0}", keyword);

            var result = await Tokens.Search.TweetsAsync(count => num, q => keyword, max_id => maxid);

            Func <CoreTweet.Status, ITweet> tweetSelector = status => TweetFactory.Create(status);

            return(result.Select(tweetSelector));
        }
예제 #3
0
        public async Task <IEnumerable <ITweet> > GetUserTimeline(string screenName, bool excludeReply = false, bool includeRetweet = false)
        {
            Debug.WriteLine("GetTimeline Start");

            int num    = 100;
            var result = await Tokens.Statuses.UserTimelineAsync(screen_name => screenName, count => num, exclude_replies => excludeReply, include_rts => includeRetweet);

            var timeline = result;
            var tweets   = timeline.Select(status => TweetFactory.Create(status));

            Debug.WriteLine("GetTimeline End");

            return(tweets);
        }