Ejemplo n.º 1
0
 private static void fetchsourcedata(JToken item)
 {
     try
     {
         string sourceid    = item["id"].ToString();
         string domainUrl   = item["url"].ToString();
         string category    = item["category"].ToString();
         string newsdataurl = "https://newsapi.org/v1/articles?source=" + sourceid + "&sortBy=latest&apiKey=" + AdvanceSerachData.Helper.AppSetting.newsapikey;
         string newdatas    = getHtmlfromUrl(newsdataurl);
         if (string.IsNullOrEmpty(newdatas))
         {
             newsdataurl = "https://newsapi.org/v1/articles?source=" + sourceid + "&sortBy=top&apiKey=" + AdvanceSerachData.Helper.AppSetting.newsapikey;
             newdatas    = getHtmlfromUrl(newsdataurl);
         }
         JObject newsdata = JObject.Parse(newdatas);
         foreach (var item_newsdata in newsdata["articles"])
         {
             try
             {
                 MongoRepository mongoreppo = new MongoRepository("AdvanceSerachData");
                 Domain.Socioboard.Models.Mongo.AdvanceSerachData _AdvanceSerachData = new Domain.Socioboard.Models.Mongo.AdvanceSerachData();
                 _AdvanceSerachData.Id         = ObjectId.GenerateNewId();
                 _AdvanceSerachData.strId      = ObjectId.GenerateNewId().ToString();
                 _AdvanceSerachData.domainType = domainUrl;
                 _AdvanceSerachData.postType   = Domain.Socioboard.Enum.AdvanceSearchpostType.trending;
                 if (category == "general")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.general;
                 }
                 if (category == "technology")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.technology;
                 }
                 if (category == "sport")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.sport;
                 }
                 if (category == "business")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.business;
                 }
                 if (category == "politics")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.politics;
                 }
                 if (category == "entertainment")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.entertainment;
                 }
                 if (category == "gaming")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.gaming;
                 }
                 if (category == "music")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.music;
                 }
                 if (category == "science-and-nature")
                 {
                     _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.science_and_nature;
                 }
                 try
                 {
                     _AdvanceSerachData.postUrl  = item_newsdata["url"].ToString();
                     _AdvanceSerachData.ImageUrl = item_newsdata["urlToImage"].ToString();
                     long    fbengagementCount = TwitterAdvanceSearch.fbShareCount(_AdvanceSerachData.postUrl);
                     long    redditShare       = TwitterAdvanceSearch.redditShareCount(_AdvanceSerachData.postUrl);
                     string  datacount         = TwitterAdvanceSearch.getdonreachdatafromUrl("https://free.donreach.com/shares?providers=facebook,twitter,google,pinterest,linkedin,reddit&url=" + _AdvanceSerachData.postUrl);
                     JObject shareData         = JObject.Parse(datacount);
                     long    pinshare          = Convert.ToInt32(shareData["shares"]["pinterest"].ToString());
                     long    linshare          = Convert.ToInt32(shareData["shares"]["linkedin"].ToString());
                     long    gplusshare        = Convert.ToInt32(shareData["shares"]["google"].ToString());
                     long    twittershare      = Convert.ToInt32(shareData["shares"]["twitter"].ToString());
                     _AdvanceSerachData.pinShareCount     = pinshare;
                     _AdvanceSerachData.gplusShareCount   = gplusshare;
                     _AdvanceSerachData.linShareCount     = linshare;
                     _AdvanceSerachData.twtShareCount     = twittershare;
                     _AdvanceSerachData.redditShareCount  = redditShare;
                     _AdvanceSerachData.fbengagementCount = fbengagementCount;
                     _AdvanceSerachData.totalShareCount   = Convert.ToInt64(pinshare + gplusshare + linshare + twittershare + redditShare + fbengagementCount);
                 }
                 catch { }
                 try
                 {
                     _AdvanceSerachData.title = item_newsdata["title"].ToString();
                 }
                 catch { }
                 try
                 {
                     _AdvanceSerachData.postdescription = item_newsdata["description"].ToString();
                 }
                 catch { }
                 try
                 {
                     _AdvanceSerachData.userName = item_newsdata["author"].ToString();
                 }
                 catch { }
                 try
                 {
                     _AdvanceSerachData.postedTime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(new DateTime(1970, 1, 1).AddSeconds(Convert.ToInt64(item_newsdata["publishedAt"].ToString())));
                 }
                 catch
                 {
                     _AdvanceSerachData.postedTime = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                 }
                 int count = mongoreppo.Counts <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.postUrl == _AdvanceSerachData.postUrl);
                 if (count == 0)
                 {
                     mongoreppo.Add <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(_AdvanceSerachData);
                 }
                 else
                 {
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 2
0
        private static void fetchdata(Discovery itemdis)
        {
            MongoRepository mongoreppo = new MongoRepository("AdvanceSerachData");

            try
            {
                string _dailymotionpostRestUrl = "https://api.dailymotion.com/videos/?search=" + itemdis.SearchKeyword + "&fields=id,title,created_time,url,description,owner.username, owner.screenname, owner.fullname,owner.url, owner.avatar_25_url, owner.avatar_60_url, owner.avatar_80_url, owner.avatar_120_url, owner.avatar_190_url, owner.avatar_240_url, owner.avatar_360_url, owner.avatar_480_url, owner.avatar_720_url";

                string response = WebRequst(_dailymotionpostRestUrl);

                var jdata = Newtonsoft.Json.Linq.JObject.Parse(response);

                foreach (var item in jdata["list"])
                {
                    Domain.Socioboard.Models.Mongo.AdvanceSerachData _AdvanceSerachData = new Domain.Socioboard.Models.Mongo.AdvanceSerachData();
                    _AdvanceSerachData.Id          = ObjectId.GenerateNewId();
                    _AdvanceSerachData.strId       = ObjectId.GenerateNewId().ToString();
                    _AdvanceSerachData.domainType  = "http://www.dailymotion.com/in";
                    _AdvanceSerachData.postType    = Domain.Socioboard.Enum.AdvanceSearchpostType.video;
                    _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.dailymotion;
                    try
                    {
                        _AdvanceSerachData.userName = item["owner.username"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.userName = "";
                    }
                    try
                    {
                        _AdvanceSerachData.postId = item["id"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.postId = "";
                    }
                    try
                    {
                        _AdvanceSerachData.title = item["title"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.title = "";
                    }
                    try
                    {
                        _AdvanceSerachData.videourl = item["url"].ToString();
                        long    fbengagementCount = TwitterAdvanceSearch.fbShareCount(_AdvanceSerachData.videourl);
                        long    redditShare       = TwitterAdvanceSearch.redditShareCount(_AdvanceSerachData.videourl);
                        string  datacount         = TwitterAdvanceSearch.getdonreachdatafromUrl("https://free.donreach.com/shares?providers=facebook,twitter,google,pinterest,linkedin,reddit&url=" + _AdvanceSerachData.videourl);
                        JObject shareData         = JObject.Parse(datacount);
                        long    pinshare          = Convert.ToInt32(shareData["shares"]["pinterest"].ToString());
                        long    linshare          = Convert.ToInt32(shareData["shares"]["linkedin"].ToString());
                        long    gplusshare        = Convert.ToInt32(shareData["shares"]["google"].ToString());
                        long    twittershare      = Convert.ToInt32(shareData["shares"]["twitter"].ToString());
                        _AdvanceSerachData.postUrl           = _AdvanceSerachData.videourl;
                        _AdvanceSerachData.pinShareCount     = pinshare;
                        _AdvanceSerachData.gplusShareCount   = gplusshare;
                        _AdvanceSerachData.linShareCount     = linshare;
                        _AdvanceSerachData.twtShareCount     = twittershare;
                        _AdvanceSerachData.redditShareCount  = redditShare;
                        _AdvanceSerachData.fbengagementCount = fbengagementCount;
                        _AdvanceSerachData.totalShareCount   = Convert.ToInt64(pinshare + gplusshare + linshare + twittershare + redditShare + fbengagementCount);
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.videourl = "";
                    }
                    try
                    {
                        _AdvanceSerachData.postdescription = item["description"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.postdescription = "";
                    }
                    try
                    {
                        _AdvanceSerachData.postedTime = double.Parse(item["created_time"].ToString());
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.postedTime = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                    }
                    int count = mongoreppo.Counts <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.postUrl == _AdvanceSerachData.postUrl);
                    if (count == 0)
                    {
                        mongoreppo.Add <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(_AdvanceSerachData);
                    }
                    else
                    {
                        var update = Builders <Domain.Socioboard.Models.Mongo.AdvanceSerachData> .Update.Set(t => t.linShareCount, _AdvanceSerachData.linShareCount).Set(t => t.pinShareCount, _AdvanceSerachData.pinShareCount)
                                     .Set(t => t.redditShareCount, _AdvanceSerachData.redditShareCount)
                                     .Set(t => t.twtShareCount, _AdvanceSerachData.twtShareCount)
                                     .Set(t => t.gplusShareCount, _AdvanceSerachData.gplusShareCount)
                                     .Set(t => t.fbengagementCount, _AdvanceSerachData.fbengagementCount)
                                     .Set(t => t.totalShareCount, _AdvanceSerachData.totalShareCount);

                        mongoreppo.Update <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(update, t => t.postUrl == _AdvanceSerachData.postUrl);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 3
0
        private static void fetchdata(Discovery itemdis)
        {
            MongoRepository mongoreppo = new MongoRepository("AdvanceSerachData");

            try
            {
                string youtubesearchurl = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=15&order=relevance&q=" + itemdis.SearchKeyword + "&key=AIzaSyBmQ1X1UBnKi3V78EkLuh7UHk5odrGfp5M";
                string response         = WebRequst(youtubesearchurl);
                var    Jdata            = Newtonsoft.Json.Linq.JObject.Parse(response);

                foreach (var item in Jdata["items"])
                {
                    Domain.Socioboard.Models.Mongo.AdvanceSerachData _AdvanceSerachData = new Domain.Socioboard.Models.Mongo.AdvanceSerachData();
                    _AdvanceSerachData.Id          = ObjectId.GenerateNewId();
                    _AdvanceSerachData.strId       = ObjectId.GenerateNewId().ToString();
                    _AdvanceSerachData.domainType  = "https://www.youtube.com/";
                    _AdvanceSerachData.postType    = Domain.Socioboard.Enum.AdvanceSearchpostType.video;
                    _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.youtube;
                    try
                    {
                        _AdvanceSerachData.userName = item["snippet"]["channelTitle"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.userName = "";
                    }
                    try
                    {
                        _AdvanceSerachData.postId = item["id"]["videoId"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.postId = "";
                    }
                    try
                    {
                        _AdvanceSerachData.title = item["snippet"]["title"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.title = "";
                    }
                    try
                    {
                        _AdvanceSerachData.videourl = "https://www.youtube.com/watch?v=" + _AdvanceSerachData.postId;
                        long    fbengagementCount = TwitterAdvanceSearch.fbShareCount(_AdvanceSerachData.videourl);
                        long    redditShare       = TwitterAdvanceSearch.redditShareCount(_AdvanceSerachData.videourl);
                        string  datacount         = TwitterAdvanceSearch.getdonreachdatafromUrl("https://free.donreach.com/shares?providers=facebook,twitter,google,pinterest,linkedin,reddit&url=" + _AdvanceSerachData.videourl);
                        JObject shareData         = JObject.Parse(datacount);
                        long    pinshare          = Convert.ToInt32(shareData["shares"]["pinterest"].ToString());
                        long    linshare          = Convert.ToInt32(shareData["shares"]["linkedin"].ToString());
                        long    gplusshare        = Convert.ToInt32(shareData["shares"]["google"].ToString());
                        long    twittershare      = Convert.ToInt32(shareData["shares"]["twitter"].ToString());
                        _AdvanceSerachData.postUrl           = _AdvanceSerachData.videourl;
                        _AdvanceSerachData.pinShareCount     = pinshare;
                        _AdvanceSerachData.gplusShareCount   = gplusshare;
                        _AdvanceSerachData.linShareCount     = linshare;
                        _AdvanceSerachData.twtShareCount     = twittershare;
                        _AdvanceSerachData.redditShareCount  = redditShare;
                        _AdvanceSerachData.fbengagementCount = fbengagementCount;
                        _AdvanceSerachData.totalShareCount   = Convert.ToInt64(pinshare + gplusshare + linshare + twittershare + redditShare + fbengagementCount);
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.videourl = "";
                    }
                    try
                    {
                        _AdvanceSerachData.postdescription = item["snippet"]["description"].ToString();
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.postdescription = "";
                    }
                    try
                    {
                        _AdvanceSerachData.postedTime = SBHelper.ConvertToUnixTimestamp((DateTime.Parse(item["snippet"]["publishedAt"].ToString())));
                    }
                    catch (Exception ex)
                    {
                        _AdvanceSerachData.postedTime = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                    }
                    int count = mongoreppo.Counts <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.postUrl == _AdvanceSerachData.postUrl);
                    if (count == 0)
                    {
                        mongoreppo.Add <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(_AdvanceSerachData);
                    }
                    else
                    {
                        var update = Builders <Domain.Socioboard.Models.Mongo.AdvanceSerachData> .Update.Set(t => t.linShareCount, _AdvanceSerachData.linShareCount).Set(t => t.pinShareCount, _AdvanceSerachData.pinShareCount)
                                     .Set(t => t.redditShareCount, _AdvanceSerachData.redditShareCount)
                                     .Set(t => t.twtShareCount, _AdvanceSerachData.twtShareCount)
                                     .Set(t => t.gplusShareCount, _AdvanceSerachData.gplusShareCount)
                                     .Set(t => t.fbengagementCount, _AdvanceSerachData.fbengagementCount)
                                     .Set(t => t.totalShareCount, _AdvanceSerachData.totalShareCount);

                        mongoreppo.Update <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(update, t => t.postUrl == _AdvanceSerachData.postUrl);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }