Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

125 gather video from creator #161

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- YouTube gather video from creator [#125](https://github.com/ncsa/standalone-smm-smile/issues/125)

## [0.3.5] - 2024-06-03
### Added
- YouTube most popular videos [#128](https://github.com/ncsa/standalone-smm-smile/issues/128)
Expand Down
9 changes: 6 additions & 3 deletions www/public/bootstrap/js/customized/history_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,20 @@ $.getScript("bootstrap/js/customized/view_helperFunc.js", function(){
var secondLevel = 'User Imported Data';
}
else if (key1 === 'youtube-Search') {
var secondLevel = 'YouTube Videos';
var secondLevel = 'YouTube Videos Search Results';
}
else if (key1 === 'youtube-Search-Channel') {
var secondLevel = 'YouTube Channels';
var secondLevel = 'YouTube Channels Search Results';
}
else if (key1 === 'youtube-Search-Playlist') {
var secondLevel = 'YouTube Playlists';
var secondLevel = 'YouTube Playlists Search Results';
}
else if (key1 === 'youtube-Most-Popular') {
var secondLevel = 'YouTube Most Popular Videos';
}
else if (key1 === 'youtube-Creator-Videos') {
var secondLevel = 'YouTube Creator\'s Videos';
}
else if (key1 === 'networkx') {
var secondLevel = 'Python NetworkX';
}
Expand Down
1 change: 1 addition & 0 deletions www/public/bootstrap/js/customized/query_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function authorize(platform){
$("#social-media option[value='queryYoutubeChannel']").removeAttr('disabled');
$("#social-media option[value='queryYoutubePlaylist']").removeAttr('disabled');
$("#social-media option[value='youtubeMostPopular']").removeAttr('disabled');
$("#social-media option[value='youtubeCreatorVideos']").removeAttr('disabled');
}
}

Expand Down
6 changes: 5 additions & 1 deletion www/public/bootstrap/js/customized/query_formValid.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ function formValid(searchID){
$("#alert").modal('show');
return false
}
}else if ($("#social-media option:selected").val() === 'queryYoutube' || $("#social-media option:selected").val() === 'queryYoutubePlaylist' || $("#social-media option:selected").val() === 'queryYoutubeChannel'){
}else if ($("#social-media option:selected").val() === 'queryYoutube'
|| $("#social-media option:selected").val() === 'queryYoutubePlaylist'
|| $("#social-media option:selected").val() === 'queryYoutubeChannel'
|| $("#social-media option:selected").val() === 'youtubeCreatorVideos'
){
if ($("#ytDateRange").is(':checked') &&
($("#publishedAfter").val() === '' || $("#publishedBefore").val() === '' || $("#publishedAfter").val()>$("#publishedBefore").val())){
$("#modal-message").append(`<h4>Please sepecify a date range, and the publishing after date cannot be later than the publishing before date!</h4>`);
Expand Down
94 changes: 61 additions & 33 deletions www/public/bootstrap/js/customized/query_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function init(){
youtubeSearchChannel:{},
youtubeSearchPlaylist:{},
youtubeMostPopular:{},
youtubeCreatorVideos:{},
};

// initialization
Expand Down Expand Up @@ -138,37 +139,29 @@ function init(){
parameters['psComment']['fields']=`\n\t\t\tcomment_author_name\n\t\t\tbody\n\t\t\tcomment_created\n\t\t\tid\n\t\t\tlink_id\n\t\t\tparent_id`+
`\n\t\t\tcomment_score\n\t\t\tsubreddit_display_name\n\t\t\tsubreddit_name_prefixed\n\t\t\tsubreddit_id`;

parameters['youtubeSearch']['q:'] = keyword;
parameters['youtubeSearch']['order:'] = "relevance";
parameters['youtubeSearch']['videoDuration:'] = "any";
parameters['youtubeSearch']['fields'] = "\n\t\t\tkind\n\t\t\tetag\n\t\t\tid{\n\t\t\t\tkind\n\t\t\t\tvideoId\n\t\t\t\tchannelId\n\t\t\t\tplaylistId\n\t\t\t}" +
const youtubeCommonFields = "\n\t\t\tkind\n\t\t\tetag\n\t\t\tid{\n\t\t\t\tkind\n\t\t\t\tvideoId\n\t\t\t\tchannelId\n\t\t\t\tplaylistId\n\t\t\t}" +
"\n\t\t\tsnippet{\n\t\t\t\tpublishedAt\n\t\t\t\tchannelId\n\t\t\t\ttitle\n\t\t\t\tdescription\n\t\t\t\tdefault_thumbnails_url" +
"\n\t\t\t\tdefault_thumbnails_width\n\t\t\t\tdefault_thumbnails_height\n\t\t\t\tmedium_thumbnails_url\n\t\t\t\tmedium_thumbnails_width" +
"\n\t\t\t\tmedium_thumbnails_height\n\t\t\t\thigh_thumbnails_url\n\t\t\t\thigh_thumbnails_width\n\t\t\t\thigh_thumbnails_height" +
"\n\t\t\t\tstandard_thumbnails_url\n\t\t\t\tstandard_thumbnails_width\n\t\t\t\tstandard_thumbnails_height\n\t\t\t\tmaxres_thumbnails_url" +
"\n\t\t\t\tmaxres_thumbnails_width\n\t\t\t\thigh_thumbnails_height\n\t\t\t\tchannelTitle\n\t\t\t\tliveBroadcastContent\n\t\t\t}";

parameters['youtubeSearch']['q:'] = keyword;
parameters['youtubeSearch']['order:'] = "relevance";
parameters['youtubeSearch']['videoDuration:'] = "any";
parameters['youtubeSearch']['fields'] = youtubeCommonFields;

parameters['youtubeSearchChannel']['q:'] = keyword;
parameters['youtubeSearchChannel']['type:'] = "channel";
parameters['youtubeSearchChannel']['order:'] = "relevance";
parameters['youtubeSearchChannel']['videoDuration:'] = "any";
parameters['youtubeSearchChannel']['fields'] = "\n\t\t\tkind\n\t\t\tetag\n\t\t\tid{\n\t\t\t\tkind\n\t\t\t\tvideoId\n\t\t\t\tchannelId\n\t\t\t\tplaylistId\n\t\t\t}" +
"\n\t\t\tsnippet{\n\t\t\t\tpublishedAt\n\t\t\t\tchannelId\n\t\t\t\ttitle\n\t\t\t\tdescription\n\t\t\t\tdefault_thumbnails_url" +
"\n\t\t\t\tdefault_thumbnails_width\n\t\t\t\tdefault_thumbnails_height\n\t\t\t\tmedium_thumbnails_url\n\t\t\t\tmedium_thumbnails_width" +
"\n\t\t\t\tmedium_thumbnails_height\n\t\t\t\thigh_thumbnails_url\n\t\t\t\thigh_thumbnails_width\n\t\t\t\thigh_thumbnails_height" +
"\n\t\t\t\tstandard_thumbnails_url\n\t\t\t\tstandard_thumbnails_width\n\t\t\t\tstandard_thumbnails_height\n\t\t\t\tmaxres_thumbnails_url" +
"\n\t\t\t\tmaxres_thumbnails_width\n\t\t\t\thigh_thumbnails_height\n\t\t\t\tchannelTitle\n\t\t\t\tliveBroadcastContent\n\t\t\t}";
parameters['youtubeSearchChannel']['fields'] = youtubeCommonFields;

parameters['youtubeSearchPlaylist']['q:'] = keyword;
parameters['youtubeSearchPlaylist']['type:'] = "playlist";
parameters['youtubeSearchPlaylist']['order:'] = "relevance";
parameters['youtubeSearchPlaylist']['videoDuration:'] = "any";
parameters['youtubeSearchPlaylist']['fields'] = "\n\t\t\tkind\n\t\t\tetag\n\t\t\tid{\n\t\t\t\tkind\n\t\t\t\tvideoId\n\t\t\t\tchannelId\n\t\t\t\tplaylistId\n\t\t\t}" +
"\n\t\t\tsnippet{\n\t\t\t\tpublishedAt\n\t\t\t\tchannelId\n\t\t\t\ttitle\n\t\t\t\tdescription\n\t\t\t\tdefault_thumbnails_url" +
"\n\t\t\t\tdefault_thumbnails_width\n\t\t\t\tdefault_thumbnails_height\n\t\t\t\tmedium_thumbnails_url\n\t\t\t\tmedium_thumbnails_width" +
"\n\t\t\t\tmedium_thumbnails_height\n\t\t\t\thigh_thumbnails_url\n\t\t\t\thigh_thumbnails_width\n\t\t\t\thigh_thumbnails_height" +
"\n\t\t\t\tstandard_thumbnails_url\n\t\t\t\tstandard_thumbnails_width\n\t\t\t\tstandard_thumbnails_height\n\t\t\t\tmaxres_thumbnails_url" +
"\n\t\t\t\tmaxres_thumbnails_width\n\t\t\t\thigh_thumbnails_height\n\t\t\t\tchannelTitle\n\t\t\t\tliveBroadcastContent\n\t\t\t}";
parameters['youtubeSearchPlaylist']['fields'] = youtubeCommonFields;

parameters['youtubeMostPopular']['regionCode:'] = keyword;
parameters['youtubeMostPopular']['chart:'] = "mostPopular";
Expand All @@ -194,10 +187,14 @@ function init(){
"actualStartTime\n\t\t\t\tactualEndTime\n\t\t\t\tscheduledStartTime\n\t\t\t\tscheduledEndTime" +
"\n\t\t\t\tconcurrentViewers\n\t\t\t\tactiveLiveChatId\n\t\t\t}"

parameters['youtubeCreatorVideos']['handle:'] = keyword;
parameters['youtubeCreatorVideos']['order:'] = "relevance";
parameters['youtubeCreatorVideos']['videoDuration:'] = "any";
parameters['youtubeCreatorVideos']['fields'] = youtubeCommonFields;

Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);


}
else {
$("#modal-message").append(`<h4>We currently don't support advanced settings for this search function.</h4>`);
Expand Down Expand Up @@ -321,20 +318,34 @@ function init(){
$("#searchbox").attr("placeholder","Keyword that you wish to search...");
$("boolean").tooltip('hide');
}
else if ( queryTerm === 'queryYoutube' || queryTerm === 'queryYoutubeChannel' || queryTerm === 'queryYoutubePlaylist'){
else if ( queryTerm === 'queryYoutube' || queryTerm === 'queryYoutubeChannel' || queryTerm === 'queryYoutubePlaylist'
|| queryTerm === 'youtubeCreatorVideos'){

var placeholderText = "Keywords for the Youtube content that you wish to search...";
if (queryTerm === 'queryYoutube') $(".youtube-search").show();
if (queryTerm === 'queryYoutubeChannel') $(".youtube-search-channel").show();
if (queryTerm === 'queryYoutubePlaylist') $(".youtube-search-playlist").show();
$("#searchbox").attr("placeholder","Keywords for the Youtube content that you wish to search...");

// tooltip to show YouTube rules
$("boolean").attr('data-original-title',
"YouTube keyword search supports boolean NOT (-) and OR (|) operators to exclude videos or to find videos " +
"that are associated with one of several search terms. Details please refer to the&nbsp" +
"<a href='https://developers.google.com/youtube/v3/docs/search/list#parameters' target='_blank'>" +
"API documentations</a>")
.tooltip('fixTitle')
.tooltip('show');
if (queryTerm === 'youtubeCreatorVideos') {
$(".youtube-creator-videos").show();
placeholderText = "A single YouTuber creator handle. e.g. MrBeast"
}
$("#searchbox").attr("placeholder", placeholderText);

// tooltip to show YouTube search rules
if (queryTerm !== 'youtubeCreatorVideos'){
$("boolean").attr('data-original-title',
"YouTube keyword search supports boolean NOT (-) and OR (|) operators to exclude videos or to find videos " +
"that are associated with one of several search terms. Details please refer to the&nbsp" +
"<a href='https://developers.google.com/youtube/v3/docs/search/list#parameters' target='_blank'>" +
"API documentations</a>")
.tooltip('fixTitle')
.tooltip('show');
}
else{
$("boolean").attr('data-original-title', "")
.tooltip('fixTitle')
.tooltip('hide');
}
}
else if (queryTerm === 'youtubeMostPopular'){
$(".youtube-most-popular").show();
Expand Down Expand Up @@ -937,7 +948,7 @@ function init(){

});

/*----------------------------------------------------- Youtube Search-------------------------------------------------------*/
/*--------------------- Youtube Search Videos, channel, playlist, video by creator-----------------------------*/
// count
$("#youtube-count").change(function(){
Query =updateString(queryTerm,parameters);
Expand All @@ -948,6 +959,7 @@ function init(){
parameters['youtubeSearch']['order:'] = $(this).val();
parameters['youtubeSearchChannel']['order:'] = $(this).val();
parameters['youtubeSearchPlaylist']['order:'] = $(this).val();
parameters['youtubeCreatorVideos']['order:'] = $(this).val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
Expand All @@ -957,6 +969,7 @@ function init(){
parameters['youtubeSearch']['videoDuration:'] = $(this).val();
parameters['youtubeSearchChannel']['videoDuration:'] = $(this).val();
parameters['youtubeSearchPlaylist']['videoDuration:'] = $(this).val();
parameters['youtubeCreatorVideos']['videoDuration:'] = $(this).val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
Expand Down Expand Up @@ -1015,6 +1028,7 @@ function init(){
parameters['youtubeSearch']['publishedAfter:'] = publishedAfter.toISOString();
parameters['youtubeSearchChannel']['publishedAfter:'] = publishedAfter.toISOString();
parameters['youtubeSearchPlaylist']['publishedAfter:'] = publishedAfter.toISOString();
parameters['youtubeCreatorVideos']['publishedAfter:'] = publishedAfter.toISOString();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
Expand All @@ -1023,6 +1037,7 @@ function init(){
parameters['youtubeSearch']['publishedBefore:'] = publishedBefore.toISOString();
parameters['youtubeSearchChannel']['publishedBefore:'] = publishedBefore.toISOString();
parameters['youtubeSearchPlaylist']['publishedBefore:'] = publishedBefore.toISOString();
parameters['youtubeCreatorVideos']['publishedBefore:'] = publishedBefore.toISOString();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
Expand All @@ -1032,9 +1047,13 @@ function init(){
parameters['youtubeSearch']['publishedAfter:'] = '';
parameters['youtubeSearchChannel']['publishedAfter:'] = '';
parameters['youtubeSearchPlaylist']['publishedAfter:'] = '';
parameters['youtubeSearchChannel']['publishedBefore:'] = '';
parameters['youtubeCreatorVideos']['publishedAfter:'] = '';

parameters['youtubeSearch']['publishedBefore:'] = '';
parameters['youtubeSearchChannel']['publishedBefore:'] = '';
parameters['youtubeSearchPlaylist']['publishedBefore:'] = '';
parameters['youtubeCreatorVideos']['publishedBefore:'] = '';

Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
if ( $('.dropdown.dropdown-lg.open').length ){
Expand All @@ -1050,19 +1069,23 @@ function init(){
$(".form-group.ytGeoSearch").show();
$("#ytLocation").change(function(){
parameters['youtubeSearch']['location:'] = $("#ytLocation").val();
parameters['youtubeCreatorVideos']['location:'] = $("#ytLocation").val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
$("#ytLocationRadius").change(function(){
parameters['youtubeSearch']['locationRadius:'] = $("#ytLocationRadius").val();
parameters['youtubeCreatorVideos']['locationRadius:'] = $("#ytLocationRadius").val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
}
else {
$(".form-group.ytGeoSearch").hide();
parameters['youtubeSearch']['location:'] = '';
parameters['youtubeCreatorVideos']['location:'] = '';
parameters['youtubeSearch']['locationRadius:'] = '';
parameters['youtubeCreatorVideos']['locationRadius:'] = '';
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
if ( $('.dropdown.dropdown-lg.open').length ){
Expand All @@ -1072,7 +1095,7 @@ function init(){

});

/*---------------------------------------------- Youtube Most popular---------------------------------------*/
/*---------------------------------------------- Youtube most popular---------------------------------------*/
$("#youtube-most-popular-count").change(function(){
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
Expand Down Expand Up @@ -1168,6 +1191,9 @@ function updateString(queryTerm, parameters){
else if (queryTerm === 'youtubeMostPopular'){
query = `\tyoutube{\n\t\tvideos(${constructQuery(parameters.youtubeMostPopular)}\n\t\t}\n\t}`;
}
else if (queryTerm === 'youtubeCreatorVideos'){
query = `\tyoutube{\n\t\tvideosByHandle(${constructQuery(parameters.youtubeCreatorVideos)}\n\t\t}\n\t}`;
}

return query;
}
Expand Down Expand Up @@ -1241,8 +1267,10 @@ function setHitogramInterval(freq){
}else if (queryTerm === 'queryYoutubePlaylist'){
prefix = 'youtube-Search-Playlist';
}else if (queryTerm === 'youtubeMostPopular'){
prefix = 'youtube-Most-Popular';
}
prefix = 'youtube-Most-Popular';
}else if (queryTerm === 'youtubeCreatorVideos'){
prefix = 'youtube-Creator-Videos'
}

if (prefix === undefined || filename === '' || filename === undefined){
$("#modal-message").append(`<h4>Incomplete information for histogram. Please make sure you have specified a data source, as well as retrieved data first.</h4>`);
Expand Down
50 changes: 49 additions & 1 deletion www/public/bootstrap/js/customized/query_submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function submitQuery(textareaID, filenameID, dryrun = false) {
prefix = 'youtube-Most-Popular';
params = parameters.youtubeMostPopular;
pages = parseInt($("#youtube-most-popular-count").val()) / 50;
} else if (queryTerm === 'youtubeCreatorVideos') {
prefix = 'youtube-Creator-Videos';
params = parameters.youtubeCreatorVideos;
pages = parseInt($("#youtube-count").val()) / 50;
}

if (dryrun) {
Expand Down Expand Up @@ -705,6 +709,50 @@ function submitSearchbox(searchboxID, filenameID, dryrun = false) {
prefix = 'youtube-Most-Popular';
params = parameters.youtubeMostPopular;
}
else if (queryTerm === 'youtubeCreatorVideos') {
pages = 2; // TODO change me to 10 later
if (dryrun) pages = 1;
queryString = `{
youtube {
videosByHandle(handle: "${keyword}") {
kind
etag
id{
kind
videoId
channelId
playlistId
}
snippet{
publishedAt
channelId
title
description
default_thumbnails_url
default_thumbnails_width
default_thumbnails_height
medium_thumbnails_url
medium_thumbnails_width
medium_thumbnails_height
high_thumbnails_url
high_thumbnails_width
high_thumbnails_height
standard_thumbnails_url
standard_thumbnails_width
standard_thumbnails_height
maxres_thumbnails_url
maxres_thumbnails_width
high_thumbnails_height
channelTitle
liveBroadcastContent
}
}
}
}
`;
prefix = 'youtube-Creator-Videos';
params = parameters.youtubeCreatorVideos;
}

if (dryrun) {
$("#instruction").hide();
Expand Down Expand Up @@ -955,7 +1003,7 @@ function renderPreview(rendering, prefix) {
</div>`);

});
} else if (prefix === 'youtube-Search' || prefix === 'youtube-Most-Popular') {
} else if (prefix === 'youtube-Search' || prefix === 'youtube-Most-Popular' || prefix === 'youtube-Creator-Videos') {
$.each(rendering, function (i, val) {
var img_url = val && val.snippet && val.snippet.medium_thumbnails_url ? val.snippet.medium_thumbnails_url : "";
let imgElement = img_url ? `<img src="${img_url}" alt="video-img" style="width:100%;"/>` : "";
Expand Down
Loading
Loading