Skip to content

Commit

Permalink
Fixed the null error profile returning on Youtube
Browse files Browse the repository at this point in the history
  • Loading branch information
platico committed May 26, 2016
1 parent 7939c4d commit 7180eea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
24 changes: 12 additions & 12 deletions src/combiner/Combiner.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ public static void main(String[] args) throws JSONException, IOException {

if(args != null) {
// Collect Youtube comments and insert them to DB
/*YoutubeExporter.main(args);
Preprocessor.preprocessComments(args[4].split("=")[1], fc);*/
YoutubeExporter.main(args);
Preprocessor.preprocessComments(args[4].split("=")[1], fc);


// Collect tweets and insert them to DB
TwitterExporter.main(args);
Preprocessor.preprocessTweets(args[4].split("=")[1], fc);

fc.exportFrequencies(); //creates frequencies.txt - sorted alphabetically
fc.exportFrequenciesByValue(); //creates frequenciesByValue.txt - sorted by frequencies (descending order)

if(args.length >= 5) {
analyticsExtractor = new AnalyticsExtractor(args[4].split("=")[1]);
//analyticsExtractor.analyze();
}
// TwitterExporter.main(args);
// Preprocessor.preprocessTweets(args[4].split("=")[1], fc);
//
// fc.exportFrequencies(); //creates frequencies.txt - sorted alphabetically
// fc.exportFrequenciesByValue(); //creates frequenciesByValue.txt - sorted by frequencies (descending order)
//
// if(args.length >= 5) {
// analyticsExtractor = new AnalyticsExtractor(args[4].split("=")[1]);
// //analyticsExtractor.analyze();
// }
}

}
Expand Down
21 changes: 13 additions & 8 deletions src/youtube/YTCommentsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,23 @@ public ArrayList<JsonObject> collectComments(String filenameArgument) {
String authorID = snippet.getAuthorChannelId().toString();

String userURL = snippet.getAuthorGoogleplusProfileUrl();
String[] splitted = userURL.split("/");
String userID = splitted[splitted.length-1]; //gets the user ID
if(userURL!=null){ //if the user still exists

String url = String.format("https://www.googleapis.com/plus/v1/people/"+userID+"?key="+API_KEY); //creates the user api URL
String[] splitted = userURL.split("/");
String userID = splitted[splitted.length-1]; //gets the user ID

HttpGet httpGet = new HttpGet(url);
HttpEntity entity = defaultHttpClient.execute(httpGet).getEntity();
String url = String.format("https://www.googleapis.com/plus/v1/people/"+userID+"?key="+API_KEY); //creates the user api URL

String[] userDetails = getDetailsFromJSON(entity); //gets the user details
HttpGet httpGet = new HttpGet(url);
HttpEntity entity = defaultHttpClient.execute(httpGet).getEntity();

String[] userDetails = getDetailsFromJSON(entity); //gets the user details

JsonObject jsonObject = createJSONfor(comment,authorID,userDetails[0],userDetails[1],userDetails[2]);
jsons.add(jsonObject);

}

JsonObject jsonObject = createJSONfor(comment,authorID,userDetails[0],userDetails[1],userDetails[2]);
jsons.add(jsonObject);


/* Comment's replies part
Expand Down

0 comments on commit 7180eea

Please sign in to comment.