Skip to content

Commit 29bb3e5

Browse files
committed
Whitespace fix for library cpp file
1 parent bdb1c6d commit 29bb3e5

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

src/YoutubeApi.cpp

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
/*
2-
Copyright (c) 2017 Brian Lough. All right reserved.
2+
Copyright (c) 2017 Brian Lough. All right reserved.
33
4-
YoutubeApi - An Arduino wrapper for the YouTube API
4+
YoutubeApi - An Arduino wrapper for the YouTube API
55
6-
This library is free software; you can redistribute it and/or
7-
modify it under the terms of the GNU Lesser General Public
8-
License as published by the Free Software Foundation; either
9-
version 2.1 of the License, or (at your option) any later version.
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
1010
11-
This library is distributed in the hope that it will be useful,
12-
but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14-
Lesser General Public License for more details.
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
1515
16-
You should have received a copy of the GNU Lesser General Public
17-
License along with this library; if not, write to the Free Software
18-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*/
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
2020

2121

2222
#include "YoutubeApi.h"
2323

2424
YoutubeApi::YoutubeApi(String apiKey, Client &client) {
25-
_apiKey = apiKey;
26-
this->client = &client;
25+
_apiKey = apiKey;
26+
this->client = &client;
2727
}
2828

2929
String YoutubeApi::sendGetToYoutube(String command) {
3030
String headers="";
31-
String body="";
32-
bool finishedHeaders = false;
33-
bool currentLineIsBlank = true;
31+
String body="";
32+
bool finishedHeaders = false;
33+
bool currentLineIsBlank = true;
3434
long now;
3535
bool avail;
3636
// Connect with youtube api over ssl
@@ -47,26 +47,26 @@ String YoutubeApi::sendGetToYoutube(String command) {
4747
char c = client->read();
4848
//Serial.write(c);
4949

50-
if(!finishedHeaders){
51-
if (currentLineIsBlank && c == '\n') {
52-
finishedHeaders = true;
53-
}
54-
else{
55-
headers = headers + c;
56-
57-
}
58-
} else {
59-
if (ch_count < maxMessageLength) {
60-
body=body+c;
61-
ch_count++;
62-
}
63-
}
64-
65-
if (c == '\n') {
66-
currentLineIsBlank = true;
67-
}else if (c != '\r') {
68-
currentLineIsBlank = false;
69-
}
50+
if(!finishedHeaders){
51+
if (currentLineIsBlank && c == '\n') {
52+
finishedHeaders = true;
53+
}
54+
else{
55+
headers = headers + c;
56+
57+
}
58+
} else {
59+
if (ch_count < maxMessageLength) {
60+
body=body+c;
61+
ch_count++;
62+
}
63+
}
64+
65+
if (c == '\n') {
66+
currentLineIsBlank = true;
67+
}else if (c != '\r') {
68+
currentLineIsBlank = false;
69+
}
7070

7171
avail=true;
7272
}
@@ -79,34 +79,34 @@ String YoutubeApi::sendGetToYoutube(String command) {
7979
}
8080
}
8181

82-
//int lastCharIndex = body.lastIndexOf("}");
82+
//int lastCharIndex = body.lastIndexOf("}");
8383

8484
//return body.substring(0,lastCharIndex+1);
85-
return body;
85+
return body;
8686
}
8787

8888
bool YoutubeApi::getChannelStatistics(String channelId){
89-
String command="https://www.googleapis.com/youtube/v3/channels?part=statistics&id="+channelId; //If you can't find it(for example if you have a custom url) look here: https://www.youtube.com/account_advanced
90-
String response = sendGetToYoutube(command); //recieve reply from youtube
91-
DynamicJsonBuffer jsonBuffer;
92-
JsonObject& root = jsonBuffer.parseObject(response);
93-
if(root.success()) {
94-
if (root.containsKey("items")) {
95-
long subscriberCount = root["items"][0]["statistics"]["subscriberCount"];
96-
long viewCount = root["items"][0]["statistics"]["viewCount"];
97-
long commentCount = root["items"][0]["statistics"]["commentCount"];
98-
long hiddenSubscriberCount = root["items"][0]["statistics"]["hiddenSubscriberCount"];
99-
long videoCount = root["items"][0]["statistics"]["videoCount"];
100-
101-
channelStats.viewCount = viewCount;
102-
channelStats.subscriberCount = subscriberCount;
103-
channelStats.commentCount = commentCount;
104-
channelStats.hiddenSubscriberCount = hiddenSubscriberCount;
105-
channelStats.videoCount = videoCount;
106-
107-
return true;
108-
}
109-
}
110-
111-
return false;
89+
String command="https://www.googleapis.com/youtube/v3/channels?part=statistics&id="+channelId; //If you can't find it(for example if you have a custom url) look here: https://www.youtube.com/account_advanced
90+
String response = sendGetToYoutube(command); //recieve reply from youtube
91+
DynamicJsonBuffer jsonBuffer;
92+
JsonObject& root = jsonBuffer.parseObject(response);
93+
if(root.success()) {
94+
if (root.containsKey("items")) {
95+
long subscriberCount = root["items"][0]["statistics"]["subscriberCount"];
96+
long viewCount = root["items"][0]["statistics"]["viewCount"];
97+
long commentCount = root["items"][0]["statistics"]["commentCount"];
98+
long hiddenSubscriberCount = root["items"][0]["statistics"]["hiddenSubscriberCount"];
99+
long videoCount = root["items"][0]["statistics"]["videoCount"];
100+
101+
channelStats.viewCount = viewCount;
102+
channelStats.subscriberCount = subscriberCount;
103+
channelStats.commentCount = commentCount;
104+
channelStats.hiddenSubscriberCount = hiddenSubscriberCount;
105+
channelStats.videoCount = videoCount;
106+
107+
return true;
108+
}
109+
}
110+
111+
return false;
112112
}

0 commit comments

Comments
 (0)