Beispiel #1
0
        public static YoutubeChannel ForUsername(this YoutubeChannel channel, string username)
        {
            var settings = channel.Settings.Clone();

            settings.ForUsername = username;
            return(Channel(settings, channel.PartTypes.ToArray()));
        }
Beispiel #2
0
        private void UpdateYoutubeReport(YoutubeChannel youtubeAccount, DatabaseRepository databaseRepository)
        {
            try
            {
                var ObjYAnalytics = new YAnalytics(AppSettings.googleClientId, AppSettings.googleClientSecret, AppSettings.googleRedirectionUrl);

                var count90AnalyticsUpdated = GetCountForMongo(youtubeAccount);

                if (!youtubeAccount.Days90Update || count90AnalyticsUpdated < 90)
                {
                    CreateReportsFor90Days(youtubeAccount, databaseRepository, ObjYAnalytics);
                }
                else
                {
                    if (youtubeAccount.LastReport_Update.AddHours(24) < DateTime.UtcNow)
                    {
                        CreateReportsForDailyWise(youtubeAccount, databaseRepository, ObjYAnalytics);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 public int InsertOrUpdateYoutubeChannel(YoutubeChannelDto channelDto)
 {
     using (var scope = new TransactionScope())
     {
         var channel = _unitOfWork.YoutubeChannelRepository.GetSingle(p => p.YoutubeChannelId == channelDto.YoutubeChannelId);
         if (channel != null)
         {
             channel.Description      = channelDto.Description;
             channel.Name             = channelDto.Name;
             channel.UploadPlaylistId = channelDto.UploadPlaylistId;
             _unitOfWork.YoutubeChannelRepository.Update(channel);
         }
         else
         {
             var newchannel = new YoutubeChannel()
             {
                 Description      = channelDto.Description,
                 Name             = channelDto.Name,
                 UploadPlaylistId = channelDto.UploadPlaylistId,
                 YoutubeChannelId = channelDto.YoutubeChannelId
             };
             _unitOfWork.YoutubeChannelRepository.Insert(newchannel);
             _unitOfWork.Save();
             channel = newchannel;
         }
         scope.Complete();
         return(channel.Id);
     }
 }
    IEnumerator YoutubeSearchChannel(string keyword, int maxresult, YoutubeSearchOrderFilter order, YoutubeSafeSearchFilter safeSearch, Action <YoutubeChannel[]> callback)
    {
        keyword = keyword.Replace(" ", "%20");

        string orderFilter, safeSearchFilter;

        orderFilter = "";
        if (order != YoutubeSearchOrderFilter.none)
        {
            orderFilter = "&order=" + order.ToString();
        }
        safeSearchFilter = "&safeSearch=" + safeSearch.ToString();


        WWW call = new WWW("https://www.googleapis.com/youtube/v3/search/?q=" + keyword + "&type=channel&maxResults=" + maxresult + "&part=snippet,id&key=" + APIKey + "" + orderFilter + "" + safeSearchFilter);

        yield return(call);

        Debug.Log(call.url);
        JSONNode result = JSON.Parse(call.text);

        channels = new YoutubeChannel[result["items"].Count];
        for (int itemsCounter = 0; itemsCounter < channels.Length; itemsCounter++)
        {
            channels[itemsCounter]             = new YoutubeChannel();
            channels[itemsCounter].id          = result["items"][itemsCounter]["id"]["channelId"];
            channels[itemsCounter].title       = result["items"][itemsCounter]["snippet"]["title"];
            channels[itemsCounter].description = result["items"][itemsCounter]["snippet"]["description"];
            channels[itemsCounter].thumbnail   = result["items"][itemsCounter]["snippet"]["thumbnails"]["high"]["url"];
        }
        callback.Invoke(channels);
    }
Beispiel #5
0
        private void ParseAndUpdateAccountDetails(YoutubeChannel youtubeChannel, DatabaseRepository databaseRepository, Video objVideo)
        {
            try
            {
                var _grpProfile = databaseRepository.Find <Groupprofiles>(t => t.profileId.Contains(youtubeChannel.YtubeChannelId)).ToList();

                var ChannelInfo  = objVideo.GetChannelInfo(AppSettings.googleApiKey, youtubeChannel.YtubeChannelId);
                var JChannelInfo = JObject.Parse(ChannelInfo);

                var cmntsCount  = objVideo.GetChannelCmntCount(AppSettings.googleApiKey, youtubeChannel.YtubeChannelId);
                var JcmntsCount = JObject.Parse(cmntsCount);

                youtubeChannel.CommentsCount = Convert.ToDouble(JcmntsCount.SelectToken("pageInfo.totalResults")?.ToString() ?? "0");

                youtubeChannel.YtubeChannelName = JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("snippet.title")?.ToString();
                _grpProfile.Select(s => { s.profileName = JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("snippet.title")?.ToString(); return(s); }).ToList();
                youtubeChannel.ChannelpicUrl = JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("snippet.thumbnails.default.url")?.ToString()?.Replace(".jpg", "");
                _grpProfile.Select(s => { s.profilePic = JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("snippet.thumbnails.default.url")?.ToString()?.Replace(".jpg", ""); return(s); }).ToList();
                youtubeChannel.YtubeChannelDescription = JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("snippet.description")?.ToString() ?? "No Description";
                youtubeChannel.SubscribersCount        = Convert.ToDouble(JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("statistics.subscriberCount")?.ToString() ?? "0");
                youtubeChannel.VideosCount             = Convert.ToDouble(JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("statistics.videoCount")?.ToString() ?? "0");
                youtubeChannel.ViewsCount = Convert.ToDouble(JChannelInfo.SelectTokens("items")?.FirstOrDefault()?.FirstOrDefault()?.SelectToken("statistics.viewCount")?.ToString() ?? "0");

                foreach (var youtubeChannel_grpProfile in _grpProfile)
                {
                    databaseRepository.Update(youtubeChannel_grpProfile);
                }

                youtubeChannel.LastUpdate = DateTime.UtcNow;
                databaseRepository.Update(youtubeChannel);
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #6
0
 public static YoutubePlaylistItems Uploads(this YoutubeChannel channel)
 {
     if (channel.UploadsPlaylistId == null)
     {
         channel = channel.RequestContentDetails();
     }
     return(PlaylistItems(channel.UploadsPlaylistId));
 }
Beispiel #7
0
 public static YoutubeChannel RequestAllParts(this YoutubeChannel channel)
 {
     return(channel.RequestContentDetails()
            .RequestBrandingSettings()
            .RequestContentOwnerDetails()
            .RequestLocalizations()
            .RequestStatistics()
            .RequestStatus()
            .RequestTopicDetails()
            .RequestSnippet());
 }
Beispiel #8
0
 public StoredChannel(YoutubeChannel channel)
 {
     ChannelId        = channel.ChannelId;
     Name             = channel.ChannelTitle;
     Active           = true;
     Link             = "https://www.youtube.com/channel/" + ChannelId;
     BestImageUrl     = GrabUrl(channel.Snippet.Thumbnails.maxres);
     HighImageUrl     = GrabUrl(channel.Snippet.Thumbnails.high);
     MediumImageUrl   = GrabUrl(channel.Snippet.Thumbnails.medium);
     StandardImageUrl = GrabUrl(channel.Snippet.Thumbnails.standard);
 }
Beispiel #9
0
    public static void Main()
    {
        YoutubeChannel s = new YoutubeChannel("state 1")
        {
            new YoutubeSubscriber("ob1"),
            new YoutubeSubscriber("ob2"),
            new YoutubeSubscriber("ob3"),
        };

        s += new YoutubeSubscriber("ob4");
        s.SetState("Text Changed!");
    }
Beispiel #10
0
        private static int GetCountForMongo(YoutubeChannel youtubeAccount)
        {
            var mongoreposs = new MongoRepository("YoutubeReportsData");
            var result      = mongoreposs.Find <YoutubeReports>(t => t.channelId.Equals(youtubeAccount.YtubeChannelId));
            var task        = Task.Run(async() =>
            {
                return(await result);
            });
            var lstYanalytics           = task.Result;
            var count90AnalyticsUpdated = lstYanalytics.Count();

            return(count90AnalyticsUpdated);
        }
Beispiel #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (HasSharedSet)
            {
                hash ^= SharedSet.GetHashCode();
            }
            if (HasCriterionId)
            {
                hash ^= CriterionId.GetHashCode();
            }
            if (Type != global::Google.Ads.GoogleAds.V9.Enums.CriterionTypeEnum.Types.CriterionType.Unspecified)
            {
                hash ^= Type.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.Keyword)
            {
                hash ^= Keyword.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.YoutubeVideo)
            {
                hash ^= YoutubeVideo.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.YoutubeChannel)
            {
                hash ^= YoutubeChannel.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.Placement)
            {
                hash ^= Placement.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.MobileAppCategory)
            {
                hash ^= MobileAppCategory.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.MobileApplication)
            {
                hash ^= MobileApplication.GetHashCode();
            }
            hash ^= (int)criterionCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (sharedSet_ != null)
            {
                hash ^= SharedSet.GetHashCode();
            }
            if (criterionId_ != null)
            {
                hash ^= CriterionId.GetHashCode();
            }
            if (Type != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.Keyword)
            {
                hash ^= Keyword.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.YoutubeVideo)
            {
                hash ^= YoutubeVideo.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.YoutubeChannel)
            {
                hash ^= YoutubeChannel.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.Placement)
            {
                hash ^= Placement.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.MobileAppCategory)
            {
                hash ^= MobileAppCategory.GetHashCode();
            }
            if (criterionCase_ == CriterionOneofCase.MobileApplication)
            {
                hash ^= MobileApplication.GetHashCode();
            }
            hash ^= (int)criterionCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 public static void Add(YoutubeChannel YoutubeChannel)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start and open Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to save data.
             session.Save(YoutubeChannel);
             transaction.Commit();
         } //End Using trasaction
     }     //End Using session
 }
Beispiel #14
0
        private void UpdateYoutubeFeeds(YoutubeChannel youtubeChannel)
        {
            if (youtubeChannel.LastUpdate.AddHours(1) <= DateTime.UtcNow)
            {
                if (youtubeChannel.IsActive)
                {
                    var objoAuthTokenYtubes = new oAuthTokenYoutube(AppSettings.googleClientId, AppSettings.googleClientSecret, AppSettings.googleRedirectionUrl);
                    var objToken            = new oAuthToken(AppSettings.googleClientId, AppSettings.googleClientSecret, AppSettings.googleRedirectionUrl);
                    var objVideo            = new Video(AppSettings.googleClientId, AppSettings.googleClientSecret, AppSettings.googleRedirectionUrl);
                    var databaseRepository  = new DatabaseRepository();

                    ParseAndUpdateAccountDetails(youtubeChannel, databaseRepository, objVideo);
                    YoutubeFeedsfetch.ParseAndUpdateFeeds(youtubeChannel.YtubeChannelId);
                }
            }
        }
Beispiel #15
0
        private async Task CheckForNewVideo(YoutubeChannel youtubeChannel)
        {
            HttpResponseMessage response;

            try
            {
                response = httpClient.GetAsync(youtubeChannel.VideoUrl).Result;
            }
            catch (Exception ex)
            {
                await Log(new LogMessage(LogSeverity.Error, "CheckForNewVideo", $"Something went wrong when checking channel {youtubeChannel.Name}", ex));

                return;
            }

            string body = response.Content.ReadAsStringAsync().Result;

            var match = videoRegex.Match(body);

            var newVideoId = match.Groups[1].Value;

            if (string.IsNullOrEmpty(newVideoId))
            {
                return;
            }

            if (youtubeChannel.LastVideoId == null)
            {
                youtubeChannel.LastVideoId = match.Groups[1].Value;
                SaveToDisk();
                return;
            }
            else if (youtubeChannel.LastVideoId != match.Groups[1].Value)
            {
                string newVideoUrl = $"https://www.youtube.com/watch?v={match.Groups[1].Value}";
                await Log(new LogMessage(LogSeverity.Info, "CheckForNewVideo", $"New Youtube video for: {youtubeChannel.Name}"));

                if (await commandHandlingService.SendMessageAsync(youtubeChannel.DiscordChannelId, newVideoUrl))
                {
                    youtubeChannel.LastVideoId = match.Groups[1].Value;
                    SaveToDisk();
                }
                return;
            }
        }
Beispiel #16
0
        public void Run()
        {
            //Observer
            YoutubeChannel ericHewettChannel = new YoutubeChannel();
            ISubscriber    jerry             = new Moderator();

            Observer.ISubscriber bill = new User();
            Observer.ISubscriber ben  = new User();

            ericHewettChannel.subscribe(jerry);
            ericHewettChannel.subscribe(bill);
            ericHewettChannel.subscribe(ben);

            ericHewettChannel.notifySubscriber();
            Console.ReadKey();
            ericHewettChannel.unsubscribe(bill);
            ericHewettChannel.notifySubscriber();
            Console.ReadKey();
        }
        void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
        {
            YoutubeChannel item     = (YoutubeChannel)e.Item;
            bool           isActive = App.ChannelsDatastore.Exists(item.ChannelId);

            item.IsActive = !isActive;
            if (!isActive)
            {
                App.ChannelsDatastore.AddUpdate(new Models.StoredChannel(item));
            }
            else
            {
                App.ChannelsDatastore.Delete(item.ChannelId);
            }

            ChannelsAddRemoveEvent addRemove = new ChannelsAddRemoveEvent(item.IsActive, item.ChannelId);

            MessagingCenter.Send(addRemove, ChannelsViewModel.EVENT_ADDREMOVE);
        }
        public YTSetting(SettingsPageControlleur a_settingcontrolleur, YoutubeChannel a_channel)
        {
            InitializeComponent();
            m_settingcontrolleur = a_settingcontrolleur;

            if (a_channel != null)
            {
                m_BufferChannel  = a_channel;
                ChannelName.Text = a_channel.ChannelName;
                ChannelLink.Text = a_channel.ChannelLink;
                ChannelImg.Text  = a_channel.ChannelImageLink;
            }
            else
            {
                m_BufferChannel  = new YoutubeChannel();
                ChannelName.Text = "Enter NAME";
                ChannelLink.Text = "https://www.youtube.com/feeds/videos.xml?user=NAME";
            }
        }
Beispiel #19
0
        static void Main(string[] args)
        {
            YoutubeChannel adrian = new YoutubeChannel();
            ISubscriber A = new User();
            ISubscriber B = new User();
            ISubscriber C = new Moderator();

            adrian.Subscribe(A);
            adrian.Subscribe(B);
            adrian.Subscribe(C);

            adrian.NotifySubscribe();

            Console.WriteLine("unsbu");

            adrian.Unsubscribe(B);
            adrian.NotifySubscribe();

            Console.ReadKey();
        }
        /*
         *
         *  The Observer Pattern defines a one-to-many
         *      dependency between objects so that when one
         *      object changes state, all of its dependents are
         *      notified and updated automatically.
         *
         *  This is a BEHAVIOURAL pattern.
         */
        static void Main(string[] args)
        {
            YoutubeChannel channel = new YoutubeChannel();   // created new channel.

            ISubscriber Joey   = new User();
            ISubscriber Harry  = new User();
            ISubscriber Mathew = new Moderator();


            channel.Subscribe(Joey);
            channel.Subscribe(Harry);
            channel.Subscribe(Mathew);

            channel.NotifySubscribers();

            Console.WriteLine(" ");
            channel.UnSubscribe(Joey);

            channel.NotifySubscribers();

            Console.ReadLine();
        }
        public YoutubeChannel getYoutubeChannelDetailsById(string youtubeId)
        {
            YoutubeChannel result = new YoutubeChannel();

            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    // proceed action, to get all Facebook Account of User by UserId(Guid) and FbUserId(string).
                    List <YoutubeChannel> objlstfb = session.CreateQuery("from YoutubeChannel where Googleplususerid = :youtubeId ")
                                                     .SetParameter("youtubeId", youtubeId)
                                                     .List <YoutubeChannel>().ToList <YoutubeChannel>();
                    if (objlstfb.Count > 0)
                    {
                        result = objlstfb[0];
                    }
                    return(result);
                } //End Transaction
            }     //End session
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            YoutubeChannel adrian = new YoutubeChannel();
            ISubscriber    A      = new User();
            ISubscriber    B      = new User();
            ISubscriber    C      = new Moderator();


            adrian.Subscribe(A);
            adrian.Subscribe(B);
            adrian.Subscribe(C);


            adrian.NotifySubscribe();

            Console.WriteLine("unsbu");

            adrian.Unsubscribe(B);
            adrian.NotifySubscribe();

            Console.ReadKey();
        }
Beispiel #23
0
 public static YoutubeChannel RequestStatistics(this YoutubeChannel channel)
 {
     return(channel.RequestPart(PartType.Statistics));
 }
Beispiel #24
0
        public static Dictionary <Domain.Socioboard.Domain.TeamMemberProfile, Dictionary <object, List <object> > > GetUserProfilesSnapsAccordingToGroup(List <Domain.Socioboard.Domain.TeamMemberProfile> TeamMemberProfile)
        {
            User objUser = (User)System.Web.HttpContext.Current.Session["User"];
            Dictionary <Domain.Socioboard.Domain.TeamMemberProfile, Dictionary <object, List <object> > > dic_profilessnap = new Dictionary <Domain.Socioboard.Domain.TeamMemberProfile, Dictionary <object, List <object> > >();
            var dicprofilefeeds = new Dictionary <object, List <object> >();

            foreach (Domain.Socioboard.Domain.TeamMemberProfile item in TeamMemberProfile)
            {
                List <object> feeds = null;
                if (item.ProfileType == "facebook")
                {
                    feeds = new List <object>();
                    Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
                    FacebookAccount objFacebookAccount = (FacebookAccount)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.getFacebookAccountDetailsById(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(FacebookAccount)));
                    Api.FacebookFeed.FacebookFeed ApiobjFacebookFeed = new Api.FacebookFeed.FacebookFeed();
                    List <FacebookFeed>           lstFacebookFeed    = (List <FacebookFeed>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookFeed.getAllFacebookFeedsByUserIdAndProfileId(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(List <FacebookFeed>)));
                    foreach (var facebookfeed in lstFacebookFeed)
                    {
                        feeds.Add(facebookfeed);
                    }
                    dicprofilefeeds.Add(objFacebookAccount, feeds);
                    dic_profilessnap.Add(item, dicprofilefeeds);
                }

                if (item.ProfileType == "twitter")
                {
                    feeds = new List <object>();
                    Api.TwitterAccount.TwitterAccount ApiobjTwitterAccount = new Api.TwitterAccount.TwitterAccount();
                    TwitterAccount objTwitterAccount = (TwitterAccount)(new JavaScriptSerializer().Deserialize(ApiobjTwitterAccount.GetTwitterAccountDetailsById(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(TwitterAccount)));
                    Api.TwitterFeed.TwitterFeed ApiobjTwitterFeed = new Api.TwitterFeed.TwitterFeed();
                    List <TwitterFeed>          lstTwitterFeed    = (List <TwitterFeed>)(new JavaScriptSerializer().Deserialize(ApiobjTwitterFeed.GetAllTwitterFeedsByUserIdAndProfileId(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(List <TwitterFeed>)));
                    foreach (var twitterfeed in lstTwitterFeed)
                    {
                        feeds.Add(twitterfeed);
                    }
                    dicprofilefeeds.Add(objTwitterAccount, feeds);
                    dic_profilessnap.Add(item, dicprofilefeeds);
                }

                if (item.ProfileType == "linkedin")
                {
                    feeds = new List <object>();
                    Api.LinkedinAccount.LinkedinAccount ApiobjLinkedinAccount = new Api.LinkedinAccount.LinkedinAccount();
                    LinkedInAccount objLinkedInAccount = (LinkedInAccount)(new JavaScriptSerializer().Deserialize(ApiobjLinkedinAccount.GetLinkedinAccountDetailsById(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(LinkedInAccount)));
                    Api.LinkedInFeed.LinkedInFeed ApiobjLinkedInFeed = new Api.LinkedInFeed.LinkedInFeed();
                    List <LinkedInFeed>           lstLinkedInFeed    = (List <LinkedInFeed>)(new JavaScriptSerializer().Deserialize(ApiobjLinkedInFeed.GetLinkedInFeeds(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(List <LinkedInFeed>)));
                    foreach (var LinkedInFeed in lstLinkedInFeed)
                    {
                        feeds.Add(LinkedInFeed);
                    }
                    dicprofilefeeds.Add(objLinkedInAccount, feeds);
                    dic_profilessnap.Add(item, dicprofilefeeds);
                }
                if (item.ProfileType == "instagram")
                {
                    feeds = new List <object>();
                    Api.InstagramAccount.InstagramAccount ApiobjInstagramAccount = new Api.InstagramAccount.InstagramAccount();
                    InstagramAccount objInstagramAccount = (InstagramAccount)(new JavaScriptSerializer().Deserialize(ApiobjInstagramAccount.UserInformation(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(InstagramAccount)));
                    dicprofilefeeds.Add(objInstagramAccount, feeds);
                    dic_profilessnap.Add(item, dicprofilefeeds);
                }

                if (item.ProfileType == "tumblr")
                {
                    feeds = new List <object>();
                    Api.TumblrAccount.TumblrAccount ApiobjTumblrAccount = new Api.TumblrAccount.TumblrAccount();
                    TumblrAccount objTumblrAccount = (TumblrAccount)(new JavaScriptSerializer().Deserialize(ApiobjTumblrAccount.GetTumblrAccountDetailsById(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(TumblrAccount)));
                    dicprofilefeeds.Add(objTumblrAccount, feeds);
                    dic_profilessnap.Add(item, dicprofilefeeds);
                }


                if (item.ProfileType == "youtube")
                {
                    feeds = new List <object>();
                    Api.YoutubeAccount.YoutubeAccount ApiobjYoutubeAccount = new Api.YoutubeAccount.YoutubeAccount();
                    YoutubeAccount objYoutubeAccount = (YoutubeAccount)(new JavaScriptSerializer().Deserialize(ApiobjYoutubeAccount.GetYoutubeAccountDetailsById(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(YoutubeAccount)));
                    Api.YoutubeChannel.YoutubeChannel ApiobjYoutubeChannel = new Api.YoutubeChannel.YoutubeChannel();
                    YoutubeChannel        objYoutubeChannel = (YoutubeChannel)(new JavaScriptSerializer().Deserialize(ApiobjYoutubeChannel.GetAllYoutubeChannelByUserIdAndProfileId(objUser.Id.ToString(), item.ProfileId.ToString()), typeof(YoutubeChannel)));
                    List <YoutubeChannel> lstYoutubeChannel = new List <YoutubeChannel>();
                    lstYoutubeChannel.Add(objYoutubeChannel);
                    foreach (var youtubechannel in lstYoutubeChannel)
                    {
                        feeds.Add(youtubechannel);
                    }
                    dicprofilefeeds.Add(objYoutubeAccount, feeds);
                    dic_profilessnap.Add(item, dicprofilefeeds);
                }
            }
            return(dic_profilessnap);
        }
Beispiel #25
0
 public static YoutubeChannel RequestBrandingSettings(this YoutubeChannel channel)
 {
     return(channel.RequestPart(PartType.BrandingSettings));
 }
Beispiel #26
0
        private void CreateReportsFor90Days(YoutubeChannel youtubeChannelItem, DatabaseRepository databaseRepository, YAnalytics objYAnalytics)
        {
            try
            {
                ////////code of reports here///////////////////////
                var to_Date = DateTime.UtcNow;
                var to_dd   = ("0" + Convert.ToString(to_Date.Day));
                to_dd = to_dd.Substring(to_dd.Length - 2);
                var to_mm = "0" + Convert.ToString(to_Date.Month);
                to_mm = to_mm.Substring(to_mm.Length - 2);
                var to_yyyy   = Convert.ToString(to_Date.Year);
                var from_Date = DateTime.UtcNow.AddDays(-90);
                var from_dd   = "0" + Convert.ToString(from_Date.Day);
                from_dd = from_dd.Substring(from_dd.Length - 2);
                var from_mm = "0" + Convert.ToString(from_Date.Month);
                from_mm = from_mm.Substring(from_mm.Length - 2);
                var from_yyyy   = Convert.ToString(from_Date.Year);
                var YaFrom_Date = from_yyyy + "-" + from_mm + "-" + from_dd;
                var YaTo_Date   = to_yyyy + "-" + to_mm + "-" + to_dd;


                var mongorepo = new MongoRepository("YoutubeReportsData");


                var AnalyticData  = objYAnalytics.Get_YAnalytics_ChannelId(youtubeChannelItem.YtubeChannelId, youtubeChannelItem.RefreshToken, YaFrom_Date, YaTo_Date);
                var JAnalyticData = JObject.Parse(AnalyticData);

                var dataArray = (JArray)JAnalyticData["rows"];

                var datesJdata = new List <string>();
                if (dataArray != null)
                {
                    foreach (var rows in dataArray)
                    {
                        datesJdata.Add(rows[0].ToString());
                    }

                    foreach (var items in dataArray)
                    {
                        var objYtReports = new YoutubeReports();

                        objYtReports.Id                         = ObjectId.GenerateNewId();
                        objYtReports.date                       = items[0].ToString();
                        objYtReports.channelId                  = items[1].ToString();
                        objYtReports.SubscribersGained          = Convert.ToInt32(items[2]);
                        objYtReports.views                      = Convert.ToInt32(items[3]);
                        objYtReports.likes                      = Convert.ToInt32(items[4]);
                        objYtReports.comments                   = Convert.ToInt32(items[5]);
                        objYtReports.dislikes                   = Convert.ToInt32(items[7]);
                        objYtReports.subscribersLost            = Convert.ToInt32(items[8]);
                        objYtReports.averageViewDuration        = Convert.ToInt64(items[9]);
                        objYtReports.estimatedMinutesWatched    = Convert.ToInt64(items[10]);
                        objYtReports.annotationClickThroughRate = Convert.ToInt64(items[11]);
                        objYtReports.annotationCloseRate        = Convert.ToInt64(items[12]);
                        objYtReports.uniqueIdentifier           = youtubeChannelItem.YtubeChannelId + "_" + objYtReports.date;
                        objYtReports.datetime_unix              = Convert.ToDouble(UnixTimeNows(Convert.ToDateTime(objYtReports.date)));

                        mongorepo.Add(objYtReports);
                    }
                }
                else
                {
                    datesJdata.Add("Null");
                }

                for (var i = 1; i <= 90; i++)
                {
                    YoutubeReports objYreports  = new YoutubeReports();
                    DateTime       dateTimeTemp = DateTime.UtcNow.AddDays(-i);

                    var now_dd = "0" + Convert.ToString(dateTimeTemp.Day);
                    now_dd = now_dd.Substring(now_dd.Length - 2);
                    var now_mm = "0" + Convert.ToString(dateTimeTemp.Month);
                    now_mm = now_mm.Substring(now_mm.Length - 2);
                    var now_yyyy  = Convert.ToString(dateTimeTemp.Year);
                    var Ynow_Date = now_yyyy + "-" + now_mm + "-" + now_dd;

                    if (!(datesJdata.Contains(Ynow_Date)))
                    {
                        objYreports.Id                         = ObjectId.GenerateNewId();
                        objYreports.date                       = Ynow_Date;
                        objYreports.channelId                  = youtubeChannelItem.YtubeChannelId;
                        objYreports.SubscribersGained          = 0;
                        objYreports.views                      = 0;
                        objYreports.likes                      = 0;
                        objYreports.comments                   = 0;
                        objYreports.dislikes                   = 0;
                        objYreports.subscribersLost            = 0;
                        objYreports.averageViewDuration        = 0;
                        objYreports.estimatedMinutesWatched    = 0;
                        objYreports.annotationClickThroughRate = 0;
                        objYreports.annotationCloseRate        = 0;
                        objYreports.uniqueIdentifier           = youtubeChannelItem.YtubeChannelId + "_" + Ynow_Date;
                        objYreports.datetime_unix              = Convert.ToDouble(UnixTimeNows(Convert.ToDateTime(Ynow_Date)));

                        mongorepo.Add(objYreports);
                    }
                }

                youtubeChannelItem.Days90Update      = true;
                youtubeChannelItem.LastReport_Update = DateTime.UtcNow;
                databaseRepository.Update(youtubeChannelItem);
            }
            catch (Exception)
            {
                Thread.Sleep(600000);
            }
        }
Beispiel #27
0
        private void CreateReportsForDailyWise(YoutubeChannel youtubeChannelItem, DatabaseRepository databaseRepository, YAnalytics objYAnalytics)
        {
            try
            {
                //code of reports here//
                var to_Date = DateTime.UtcNow;
                var to_dd   = "0" + Convert.ToString(to_Date.Day);
                to_dd = to_dd.Substring(to_dd.Length - 2);
                var to_mm = "0" + Convert.ToString(to_Date.Month);
                to_mm = to_mm.Substring(to_mm.Length - 2);
                var to_yyyy   = Convert.ToString(to_Date.Year);
                var from_Date = DateTime.UtcNow.AddDays(-4);
                var from_dd   = "0" + Convert.ToString(from_Date.Day);
                from_dd = from_dd.Substring(from_dd.Length - 2);
                var from_mm = "0" + Convert.ToString(from_Date.Month);
                from_mm = from_mm.Substring(from_mm.Length - 2);
                var from_yyyy   = Convert.ToString(from_Date.Year);
                var YaFrom_Date = from_yyyy + "-" + from_mm + "-" + from_dd;
                var YaTo_Date   = to_yyyy + "-" + to_mm + "-" + to_dd;



                var AnalyticData  = objYAnalytics.Get_YAnalytics_ChannelId(youtubeChannelItem.YtubeChannelId, youtubeChannelItem.RefreshToken, YaFrom_Date, YaTo_Date);
                var JAnalyticData = JObject.Parse(AnalyticData);

                var dataArray = (JArray)JAnalyticData["rows"];

                var datesJdata = new List <string>();
                if (dataArray != null)
                {
                    foreach (var rows in dataArray)
                    {
                        datesJdata.Add(rows[0].ToString());
                    }

                    foreach (var items in dataArray)
                    {
                        var objYReports = new YoutubeReports();

                        objYReports.Id                         = ObjectId.GenerateNewId();
                        objYReports.date                       = items[0].ToString();
                        objYReports.channelId                  = items[1].ToString();
                        objYReports.SubscribersGained          = Convert.ToInt32(items[2]);
                        objYReports.views                      = Convert.ToInt32(items[3]);
                        objYReports.likes                      = Convert.ToInt32(items[4]);
                        objYReports.comments                   = Convert.ToInt32(items[5]);
                        objYReports.shares                     = Convert.ToInt32(items[6]);
                        objYReports.dislikes                   = Convert.ToInt32(items[7]);
                        objYReports.subscribersLost            = Convert.ToInt32(items[8]);
                        objYReports.averageViewDuration        = Convert.ToInt64(items[9]);
                        objYReports.estimatedMinutesWatched    = Convert.ToInt64(items[10]);
                        objYReports.annotationClickThroughRate = Convert.ToInt64(items[11]);
                        objYReports.annotationCloseRate        = Convert.ToInt64(items[12]);
                        objYReports.uniqueIdentifier           = youtubeChannelItem.YtubeChannelId + "_" + objYReports.date;
                        objYReports.datetime_unix              = Convert.ToDouble(UnixTimeNows(Convert.ToDateTime(objYReports.date)));


                        try
                        {
                            var mongoRepotsRepo = new MongoRepository("YoutubeReportsData");
                            var ret             = mongoRepotsRepo.Find <YoutubeReports>(t => t.uniqueIdentifier.Equals(objYReports.uniqueIdentifier));
                            var task_Reports    = Task.Run(async() =>
                            {
                                return(await ret);
                            });
                            var count_Reports = task_Reports.Result.Count;
                            if (count_Reports < 1)
                            {
                                try
                                {
                                    mongoRepotsRepo.Add(objYReports);
                                }
                                catch { }
                            }
                            else
                            {
                                try
                                {
                                    var filter = new BsonDocument("uniqueIdentifier", objYReports.uniqueIdentifier);
                                    var update = Builders <BsonDocument> .Update.Set("SubscribersGained", objYReports.SubscribersGained).Set("views", objYReports.views).Set("likes", objYReports.likes).Set("comments", objYReports.comments).Set("dislikes", objYReports.dislikes).Set("subscribersLost", objYReports.subscribersLost).Set("averageViewDuration", objYReports.averageViewDuration).Set("estimatedMinutesWatched", objYReports.estimatedMinutesWatched).Set("annotationClickThroughRate", objYReports.annotationClickThroughRate).Set("annotationCloseRate", objYReports.annotationCloseRate);

                                    mongoRepotsRepo.Update <YoutubeReports>(update, filter);
                                }
                                catch { }
                            }
                        }
                        catch { }
                    }
                }
                else
                {
                    datesJdata.Add("Null");
                }

                for (var i = 1; i <= 4; i++)
                {
                    var objYReports  = new YoutubeReports();
                    var dateTimeTemp = DateTime.UtcNow.AddDays(-i);

                    var now_dd = "0" + Convert.ToString(dateTimeTemp.Day);
                    now_dd = now_dd.Substring(now_dd.Length - 2);
                    var now_mm = "0" + Convert.ToString(dateTimeTemp.Month);
                    now_mm = now_mm.Substring(now_mm.Length - 2);
                    var now_yyyy  = Convert.ToString(dateTimeTemp.Year);
                    var Ynow_Date = now_yyyy + "-" + now_mm + "-" + now_dd;

                    if (!(datesJdata.Contains(Ynow_Date)))
                    {
                        objYReports.Id                         = ObjectId.GenerateNewId();
                        objYReports.date                       = Ynow_Date;
                        objYReports.channelId                  = youtubeChannelItem.YtubeChannelId;
                        objYReports.SubscribersGained          = 0;
                        objYReports.views                      = 0;
                        objYReports.likes                      = 0;
                        objYReports.comments                   = 0;
                        objYReports.dislikes                   = 0;
                        objYReports.subscribersLost            = 0;
                        objYReports.averageViewDuration        = 0;
                        objYReports.estimatedMinutesWatched    = 0;
                        objYReports.annotationClickThroughRate = 0;
                        objYReports.annotationCloseRate        = 0;
                        objYReports.uniqueIdentifier           = youtubeChannelItem.YtubeChannelId + "_" + Ynow_Date;
                        objYReports.datetime_unix              = Convert.ToDouble(UnixTimeNows(Convert.ToDateTime(Ynow_Date)));

                        var mongoRepotsRepo = new MongoRepository("YoutubeReportsData");
                        mongoRepotsRepo.Add(objYReports);
                    }
                }

                youtubeChannelItem.LastReport_Update = DateTime.UtcNow;
                databaseRepository.Update(youtubeChannelItem);
            }
            catch (Exception)
            {
                Thread.Sleep(600000);
            }
        }
        public void MergeFrom(SharedCriterion other)
        {
            if (other == null)
            {
                return;
            }
            if (other.ResourceName.Length != 0)
            {
                ResourceName = other.ResourceName;
            }
            if (other.sharedSet_ != null)
            {
                if (sharedSet_ == null || other.SharedSet != "")
                {
                    SharedSet = other.SharedSet;
                }
            }
            if (other.criterionId_ != null)
            {
                if (criterionId_ == null || other.CriterionId != 0L)
                {
                    CriterionId = other.CriterionId;
                }
            }
            if (other.Type != 0)
            {
                Type = other.Type;
            }
            switch (other.CriterionCase)
            {
            case CriterionOneofCase.Keyword:
                if (Keyword == null)
                {
                    Keyword = new global::Google.Ads.GoogleAds.V2.Common.KeywordInfo();
                }
                Keyword.MergeFrom(other.Keyword);
                break;

            case CriterionOneofCase.YoutubeVideo:
                if (YoutubeVideo == null)
                {
                    YoutubeVideo = new global::Google.Ads.GoogleAds.V2.Common.YouTubeVideoInfo();
                }
                YoutubeVideo.MergeFrom(other.YoutubeVideo);
                break;

            case CriterionOneofCase.YoutubeChannel:
                if (YoutubeChannel == null)
                {
                    YoutubeChannel = new global::Google.Ads.GoogleAds.V2.Common.YouTubeChannelInfo();
                }
                YoutubeChannel.MergeFrom(other.YoutubeChannel);
                break;

            case CriterionOneofCase.Placement:
                if (Placement == null)
                {
                    Placement = new global::Google.Ads.GoogleAds.V2.Common.PlacementInfo();
                }
                Placement.MergeFrom(other.Placement);
                break;

            case CriterionOneofCase.MobileAppCategory:
                if (MobileAppCategory == null)
                {
                    MobileAppCategory = new global::Google.Ads.GoogleAds.V2.Common.MobileAppCategoryInfo();
                }
                MobileAppCategory.MergeFrom(other.MobileAppCategory);
                break;

            case CriterionOneofCase.MobileApplication:
                if (MobileApplication == null)
                {
                    MobileApplication = new global::Google.Ads.GoogleAds.V2.Common.MobileApplicationInfo();
                }
                MobileApplication.MergeFrom(other.MobileApplication);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Beispiel #29
0
        public async Task <List <YoutubeActivity> > GetChannelActivityAsync(YoutubeChannel channel)
        {
            var creds = await GetGoogleUserCredentials();

            var youtubeService = new YouTubeService(
                new BaseClientService.Initializer()
            {
                HttpClientInitializer = creds,
                ApplicationName       = "IceTube"
            });

            List <YoutubeActivity> results = new List <YoutubeActivity>();

            if (!int.TryParse(_configuration["ApiLimits:MaximumActivityResults"], out int maxResultsAllowed))
            {
                maxResultsAllowed = 200;
            }

            var nextPageToken = "";

            while (nextPageToken != null && results.Count < maxResultsAllowed)
            {
                var activities = youtubeService.Activities.List("snippet,contentDetails");
                activities.MaxResults     = 50;
                activities.PublishedAfter = channel.LastCheckedAt;
                activities.ChannelId      = channel.Id;
                activities.PageToken      = nextPageToken;

                var result = await activities.ExecuteAsync();

                results.AddRange(
                    result.Items.Select(
                        x =>
                {
                    if (!Enum.TryParse(x.Snippet.Type, true, out YoutubeActivityType type))
                    {
                        type = YoutubeActivityType.Unknown;
                    }

                    return(new YoutubeActivity
                    {
                        Id = x.Id,
                        ChannelId = x.Snippet.ChannelId,
                        Title = x.Snippet.Title,
                        Description = x.Snippet.Description,
                        Type = type,
                        TypeRaw = x.Snippet.Type,
                        PublishedAt = x.Snippet.PublishedAt,
                        ThumbnailUrl = x.Snippet.Thumbnails?.Maxres?.Url,
                        VideoId = x.ContentDetails?.Upload?.VideoId
                    });
                }));

                nextPageToken = result.NextPageToken;
            }

            if (nextPageToken != null && results.Count > maxResultsAllowed)
            {
                _logger.LogWarning("Hit maximum activity download limit while getting results for channel: {channelName}, published after: {publishedAfterDate}. This will mean some uploads may have been missed. Increase the MaximumActivityResults config value or decrease the youtube channel feed update task interval to prevent this.", channel);
            }

            return(results);
        }
        public void MergeFrom(CustomerNegativeCriterion other)
        {
            if (other == null)
            {
                return;
            }
            if (other.ResourceName.Length != 0)
            {
                ResourceName = other.ResourceName;
            }
            if (other.id_ != null)
            {
                if (id_ == null || other.Id != 0L)
                {
                    Id = other.Id;
                }
            }
            if (other.Type != 0)
            {
                Type = other.Type;
            }
            switch (other.CriterionCase)
            {
            case CriterionOneofCase.ContentLabel:
                if (ContentLabel == null)
                {
                    ContentLabel = new global::Google.Ads.GoogleAds.V2.Common.ContentLabelInfo();
                }
                ContentLabel.MergeFrom(other.ContentLabel);
                break;

            case CriterionOneofCase.MobileApplication:
                if (MobileApplication == null)
                {
                    MobileApplication = new global::Google.Ads.GoogleAds.V2.Common.MobileApplicationInfo();
                }
                MobileApplication.MergeFrom(other.MobileApplication);
                break;

            case CriterionOneofCase.MobileAppCategory:
                if (MobileAppCategory == null)
                {
                    MobileAppCategory = new global::Google.Ads.GoogleAds.V2.Common.MobileAppCategoryInfo();
                }
                MobileAppCategory.MergeFrom(other.MobileAppCategory);
                break;

            case CriterionOneofCase.Placement:
                if (Placement == null)
                {
                    Placement = new global::Google.Ads.GoogleAds.V2.Common.PlacementInfo();
                }
                Placement.MergeFrom(other.Placement);
                break;

            case CriterionOneofCase.YoutubeVideo:
                if (YoutubeVideo == null)
                {
                    YoutubeVideo = new global::Google.Ads.GoogleAds.V2.Common.YouTubeVideoInfo();
                }
                YoutubeVideo.MergeFrom(other.YoutubeVideo);
                break;

            case CriterionOneofCase.YoutubeChannel:
                if (YoutubeChannel == null)
                {
                    YoutubeChannel = new global::Google.Ads.GoogleAds.V2.Common.YouTubeChannelInfo();
                }
                YoutubeChannel.MergeFrom(other.YoutubeChannel);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Beispiel #31
0
        private void AccessToken()
        {
            SocioBoard.Domain.User user = (User)Session["LoggedUser"];
            oAuthTokenYoutube      ObjoAuthTokenYoutube = new oAuthTokenYoutube();
            oAuthToken             objToken             = new oAuthToken();

            //GlobusGooglePlusLib.App.Core.PeopleController obj = new GlobusGooglePlusLib.App.Core.PeopleController();
            logger.Error("Error1:oAuthToken");

            string refreshToken = string.Empty;
            string access_token = string.Empty;


            try
            {
                string objRefresh = string.Empty;
                objRefresh = ObjoAuthTokenYoutube.GetRefreshToken(Request.QueryString["code"]);
                if (!objRefresh.StartsWith("["))
                {
                    objRefresh = "[" + objRefresh + "]";
                }
                JArray objArray = JArray.Parse(objRefresh);

                logger.Error("Error1:GetRefreshToken");

                if (!objRefresh.Contains("refresh_token"))
                {
                    logger.Error("Error0:refresh_token");
                    access_token = objArray[0]["access_token"].ToString();
                    string abc = ObjoAuthTokenYoutube.RevokeToken(access_token);
                    Response.Redirect("https://accounts.google.com/o/oauth2/auth?client_id=" + System.Configuration.ConfigurationManager.AppSettings["YtconsumerKey"] + "&redirect_uri=" + System.Configuration.ConfigurationManager.AppSettings["Ytredirect_uri"] + "&scope=https://www.googleapis.com/auth/youtube+https://www.googleapis.com/auth/youtube.readonly+https://www.googleapis.com/auth/youtubepartner+https://www.googleapis.com/auth/youtubepartner-channel-audit+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me&response_type=code&access_type=offline");
                    logger.Error("Error1:refresh_token");
                }


                foreach (var item in objArray)
                {
                    logger.Error("Abhay Item :" + item);
                    try
                    {
                        try
                        {
                            refreshToken = item["refresh_token"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                            logger.Error(ex.Message);

                            Console.WriteLine(ex.StackTrace);
                        }


                        access_token = item["access_token"].ToString();

                        break;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                }


                //Get user Profile
                #region <<Get user Profile>>
                JArray objEmail = new JArray();
                try
                {
                    objEmail = objToken.GetUserInfo("me", access_token.ToString());
                }
                catch (Exception ex)
                {
                    logger.Error("Email : " + objEmail);
                    logger.Error(ex.Message);
                }


                #endregion


                GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels();
                //Get the Channels of user

                JArray objarray = new JArray();
                try
                {
                    string part  = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString());
                    string Value = ObjChannel.Get_Channel_List(access_token, part, 50, true);
                    logger.Error("Successfully GetValus");
                    logger.Error("Value :" + Value);
                    JObject UserChannels = JObject.Parse(@Value);
                    logger.Error("Successfully Convert Jobj");
                    logger.Error("Successfully Convert Jobj");

                    objarray = (JArray)UserChannels["items"];
                    logger.Error("Successfully Convert JArr");
                }
                catch (Exception ex)
                {
                    logger.Error("UserChannels :" + ex.Message);
                }


                YoutubeAccount           objYoutubeAccount           = new YoutubeAccount();
                YoutubeChannel           objYoutubeChannel           = new YoutubeChannel();
                YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository();
                YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository();

                //put condition here to check is user already exise if exist then update else insert
                string ytuerid = "";
                foreach (var itemEmail in objEmail)
                {
                    logger.Error("itemEmail :" + itemEmail);
                    try
                    {
                        objYoutubeAccount.Id = Guid.NewGuid();
                        ytuerid = itemEmail["id"].ToString();
                        objYoutubeAccount.Ytuserid       = itemEmail["id"].ToString();
                        objYoutubeAccount.Emailid        = itemEmail["email"].ToString();
                        objYoutubeAccount.Ytusername     = itemEmail["given_name"].ToString();
                        objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString();
                        objYoutubeAccount.Accesstoken    = access_token;
                        objYoutubeAccount.Refreshtoken   = refreshToken;
                        objYoutubeAccount.Isactive       = 1;
                        objYoutubeAccount.Entrydate      = DateTime.Now;
                        objYoutubeAccount.UserId         = user.Id;
                    }
                    catch (Exception ex)
                    {
                        logger.Error("itemEmail1 :" + ex.Message);
                        logger.Error("itemEmail1 :" + ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                }

                foreach (var item in objarray)
                {
                    try
                    {
                        objYoutubeChannel.Id               = Guid.NewGuid();
                        objYoutubeChannel.Channelid        = item["id"].ToString();
                        objYoutubeChannel.Likesid          = item["contentDetails"]["relatedPlaylists"]["likes"].ToString();
                        objYoutubeChannel.Favoritesid      = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString();
                        objYoutubeChannel.Uploadsid        = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString();
                        objYoutubeChannel.Watchhistoryid   = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString();
                        objYoutubeChannel.Watchlaterid     = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString();
                        objYoutubeChannel.Googleplususerid = ytuerid;
                        try
                        {
                            string viewcnt = item["statistics"]["viewCount"].ToString();
                            objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt);

                            string videocnt = item["statistics"]["videoCount"].ToString();
                            objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt);

                            string commentcnt = item["statistics"]["commentCount"].ToString();
                            objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt);

                            string Subscribercnt = item["statistics"]["subscriberCount"].ToString();
                            objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt);

                            try
                            {
                                string str = item["statistics"]["hiddenSubscriberCount"].ToString();
                                if (str == "false")
                                {
                                    objYoutubeChannel.HiddenSubscriberCount = 0;
                                }
                                else
                                {
                                    objYoutubeChannel.HiddenSubscriberCount = 1;
                                }
                            }
                            catch (Exception ex)
                            {
                                logger.Error("aagaya1: " + ex);
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error("aagaya2: " + ex);
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("aagaya3: " + ex);
                        Console.WriteLine(ex.StackTrace);
                        logger.Error(ex.StackTrace);
                        logger.Error(ex.Message);
                    }
                }
                //YoutubeChannelRepository.Add(objYoutubeChannel);
                SocialProfile            objSocialProfile            = new SocialProfile();
                SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                objSocialProfile.Id            = Guid.NewGuid();
                objSocialProfile.UserId        = user.Id;
                objSocialProfile.ProfileId     = ytuerid;
                objSocialProfile.ProfileType   = "youtube";
                objSocialProfile.ProfileDate   = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                logger.Error("aagaya");
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);

                    if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount))
                    {
                        logger.Error("Abhay");
                        YoutubeAccountRepository.Add(objYoutubeAccount);
                        logger.Error("Abhay account add ho gaya");
                        YoutubeChannelRepository.Add(objYoutubeChannel);
                        logger.Error("Channel account add ho gaya");
                        GroupRepository        objGroupRepository = new GroupRepository();
                        SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"];
                        Groups lstDetails           = objGroupRepository.getGroupName(team.GroupId);
                        if (lstDetails.GroupName == "Socioboard")
                        {
                            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                            TeamMemberProfile           teammemberprofile = new TeamMemberProfile();
                            teammemberprofile.Id               = Guid.NewGuid();
                            teammemberprofile.TeamId           = team.Id;
                            teammemberprofile.ProfileId        = objYoutubeAccount.Ytuserid;
                            teammemberprofile.ProfileType      = "youtube";
                            teammemberprofile.StatusUpdateDate = DateTime.Now;
                            objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);
                        }
                    }
                }
                else
                {
                    logger.Error("Suraj");
                    if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount))
                    {
                        YoutubeAccountRepository.Add(objYoutubeAccount);
                        YoutubeChannelRepository.Add(objYoutubeChannel);
                    }
                    else
                    {
                        Response.Redirect("Home.aspx");
                    }
                }

                Response.Redirect("Home.aspx");
            }
            catch (Exception Err)
            {
                Console.Write(Err.Message.ToString());
                logger.Error(Err.StackTrace);
                logger.Error(Err.Message);
            }
        }