Skip to content

Commit

Permalink
Socioboard3.0 Update
Browse files Browse the repository at this point in the history
Socioboard3.0 Update
  • Loading branch information
swetasb committed Nov 13, 2017
1 parent e14e5ec commit 52685c0
Show file tree
Hide file tree
Showing 45 changed files with 3,294 additions and 593 deletions.
Binary file modified .vs/Socioboard/v14/.suo
Binary file not shown.
14 changes: 14 additions & 0 deletions src/Api.Socioboard/Controllers/DiscoveryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,19 @@ public IActionResult DiscoveryHistory(long userId)
return Ok(lstdiscovery);
}

[HttpPost("YoutubeSearch")]
public IActionResult YoutubeSearch(string q, int page, string pagecode)
{
if (page == 0)
{
List<Domain.Socioboard.Models.Mongo.YoutubeSearch> lstVideoss = Helper.GoogleHelper.YoutubeSearch(q, _appSettings);
return Ok(lstVideoss);
}
else
{
List<Domain.Socioboard.Models.Mongo.YoutubeSearch> lstVideoss = Helper.GoogleHelper.YoutubeSearchPageCode(q, pagecode, _appSettings);
return Ok(lstVideoss);
}
}
}
}
6 changes: 1 addition & 5 deletions src/Api.Socioboard/Controllers/WebHookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,7 @@ public async Task<HttpResponseMessage> Post()



try
{
_FacebookPagePost.sharedate = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss");
}
catch { }


try
{
Expand Down
147 changes: 146 additions & 1 deletion src/Api.Socioboard/Helper/GoogleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static class GoogleHelper
string channelid = item["id"].ToString();
string channelname = item["snippet"]["title"].ToString();
string channelimage = item["snippet"]["thumbnails"]["default"]["url"].ToString();
channelimage = channelimage.Replace(".jpg","");
channelimage = channelimage.Replace(".jpg", "");
string publishdate = item["snippet"]["publishedAt"].ToString();
string viewscount = item["statistics"]["viewCount"].ToString();
string commentscount = item["statistics"]["commentCount"].ToString();
Expand Down Expand Up @@ -189,5 +189,150 @@ public static class GoogleHelper
return lstYoutubeProfiles;
}

public static List<Domain.Socioboard.Models.Mongo.YoutubeSearch> YoutubeSearch(string q, Helper.AppSettings _appSettings)
{
List<Domain.Socioboard.Models.Mongo.YoutubeSearch> lstYoutubeVideos = new List<Domain.Socioboard.Models.Mongo.YoutubeSearch>();
string access_token = string.Empty;
string refresh_token = string.Empty;
Video _Search = new Video(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri);

string pageCodeinit = "";
try
{
string videosData = _Search.Get_Search_List(_appSettings.GoogleApiKey, q);
JObject JvideosData = JObject.Parse(videosData);
try
{
pageCodeinit = JvideosData["nextPageToken"].ToString();
}
catch
{ }

foreach (var item in JvideosData["items"])
{
Domain.Socioboard.Models.Mongo.YoutubeSearch _objVideosDataes = new Domain.Socioboard.Models.Mongo.YoutubeSearch();

try
{
_objVideosDataes.YtVideoId = item["id"]["videoId"].ToString();
_objVideosDataes.searchType = "video";
}
catch
{
try
{
_objVideosDataes.YtVideoId = item["id"]["playlistId"].ToString();
_objVideosDataes.searchType = "playlist";
}
catch
{
_objVideosDataes.YtVideoId = item["id"]["channelId"].ToString();
_objVideosDataes.searchType = "channel";
}
}
_objVideosDataes.YtChannelId = item["snippet"]["channelId"].ToString();
_objVideosDataes.VdoUrl = "https://www.youtube.com/watch?v=" + _objVideosDataes.YtVideoId;
_objVideosDataes.VdoTitle = item["snippet"]["title"].ToString();
_objVideosDataes.VdoPublishDate = (Convert.ToDateTime(item["snippet"]["publishedAt"].ToString())).ToString("MMM dd, yyyy");
try
{
_objVideosDataes.VdoImage = item["snippet"]["thumbnails"]["medium"]["url"].ToString();
}
catch
{
_objVideosDataes.VdoImage = item["snippet"]["thumbnails"]["default"]["url"].ToString();
}
_objVideosDataes.VdoEmbed = "https://www.youtube.com/embed/" + _objVideosDataes.YtVideoId;
_objVideosDataes.VdoDescription = item["snippet"]["description"].ToString();
_objVideosDataes.channelTitle = item["snippet"]["channelTitle"].ToString();
_objVideosDataes.Date = Convert.ToDateTime(item["snippet"]["publishedAt"].ToString());
_objVideosDataes.dateTimeUnix = DateExtension.ToUnixTimestamp(_objVideosDataes.Date);
_objVideosDataes.channelUrl = "https://www.youtube.com/channel/" + _objVideosDataes.YtChannelId;
_objVideosDataes.playlistUrl = "https://www.youtube.com/playlist?list=" + _objVideosDataes.YtVideoId;
_objVideosDataes.pageCode = pageCodeinit;
lstYoutubeVideos.Add(_objVideosDataes);

}
}
catch
{

}
return lstYoutubeVideos;
}


public static List<Domain.Socioboard.Models.Mongo.YoutubeSearch> YoutubeSearchPageCode(string q, string pagecode, Helper.AppSettings _appSettings)
{
List<Domain.Socioboard.Models.Mongo.YoutubeSearch> lstYoutubeVideos = new List<Domain.Socioboard.Models.Mongo.YoutubeSearch>();
string access_token = string.Empty;
string refresh_token = string.Empty;
Video _Search = new Video(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri);

string pageCodeinit = "";
try
{
string videosData = _Search.Get_Search_List_Page(_appSettings.GoogleApiKey, q, pagecode);
JObject JvideosData = JObject.Parse(videosData);
try
{
pageCodeinit = JvideosData["nextPageToken"].ToString();
}
catch
{ }

foreach (var item in JvideosData["items"])
{
Domain.Socioboard.Models.Mongo.YoutubeSearch _objVideosDataes = new Domain.Socioboard.Models.Mongo.YoutubeSearch();

try
{
_objVideosDataes.YtVideoId = item["id"]["videoId"].ToString();
_objVideosDataes.searchType = "video";
}
catch
{
try
{
_objVideosDataes.YtVideoId = item["id"]["playlistId"].ToString();
_objVideosDataes.searchType = "playlist";
}
catch
{
_objVideosDataes.YtVideoId = item["id"]["channelId"].ToString();
_objVideosDataes.searchType = "channel";
}
}
_objVideosDataes.YtChannelId = item["snippet"]["channelId"].ToString();
_objVideosDataes.VdoUrl = "https://www.youtube.com/watch?v=" + _objVideosDataes.YtVideoId;
_objVideosDataes.VdoTitle = item["snippet"]["title"].ToString();
_objVideosDataes.VdoPublishDate = (Convert.ToDateTime(item["snippet"]["publishedAt"].ToString())).ToString("MMM dd, yyyy");
try
{
_objVideosDataes.VdoImage = item["snippet"]["thumbnails"]["medium"]["url"].ToString();
}
catch
{
_objVideosDataes.VdoImage = item["snippet"]["thumbnails"]["default"]["url"].ToString();
}
_objVideosDataes.VdoEmbed = "https://www.youtube.com/embed/" + _objVideosDataes.YtVideoId;
_objVideosDataes.VdoDescription = item["snippet"]["description"].ToString();
_objVideosDataes.channelTitle = item["snippet"]["channelTitle"].ToString();
_objVideosDataes.Date = Convert.ToDateTime(item["snippet"]["publishedAt"].ToString());
_objVideosDataes.dateTimeUnix = DateExtension.ToUnixTimestamp(_objVideosDataes.Date);
_objVideosDataes.channelUrl = "https://www.youtube.com/channel/" + _objVideosDataes.YtChannelId;
_objVideosDataes.playlistUrl = "https://www.youtube.com/playlist?list=" + _objVideosDataes.YtVideoId;
_objVideosDataes.pageCode = pageCodeinit;
lstYoutubeVideos.Add(_objVideosDataes);

}
}
catch
{

}
return lstYoutubeVideos;
}

}
}
Loading

0 comments on commit 52685c0

Please sign in to comment.