-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d5f313
commit f03199f
Showing
8 changed files
with
152 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package orchestrators.socialmedia | ||
|
||
import cats.implicits.catsSyntaxApplicativeId | ||
import models.report.SocialNetworkSlug | ||
import play.api.Logger | ||
import sttp.client3.asynchttpclient.future.AsyncHttpClientFutureBackend | ||
import sttp.client3.HttpURLConnectionBackend | ||
import sttp.client3.UriContext | ||
import sttp.client3.basicRequest | ||
|
||
import scala.concurrent.ExecutionContext | ||
import scala.concurrent.Future | ||
|
||
class SocialBladeClient()(implicit ec: ExecutionContext) { | ||
|
||
val logger = Logger(this.getClass) | ||
AsyncHttpClientFutureBackend() | ||
|
||
def checkSocialNetworkUsername( | ||
platform: SocialNetworkSlug, | ||
username: String | ||
): Future[Option[String]] = { | ||
|
||
val request = basicRequest | ||
.get(uri"https://socialblade.com/youtube/user/carolinereceveur") | ||
.header( | ||
"User-Agent", | ||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" | ||
) | ||
|
||
val backend = HttpURLConnectionBackend() | ||
val response = request.send(backend) | ||
|
||
// val lowercaseUsername = username.toLowerCase() | ||
// val url = uri"https://socialblade.com/${platform.entryName.toLowerCase}/user/$lowercaseUsername" | ||
// val request = emptyRequest | ||
// .headers( | ||
// Header.userAgent( | ||
// "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" | ||
// ) | ||
// ) | ||
// .get(url) | ||
// .response(asString) | ||
|
||
println(s"------------------ request.toCurl = ${request.toCurl} ------------------") | ||
// | ||
// request | ||
// .send(backend) | ||
// .flatMap { response => | ||
// if (response.code.isSuccess) { | ||
// response.body match { | ||
// case Right(product) => | ||
// logger.debug(s"Call success") | ||
// Future.successful(Option.when(findUserName(product, lowercaseUsername))(lowercaseUsername)) | ||
// case Left(error) => | ||
// logger.warnWithTitle("social_blade_error", s"Error while calling Socialblade: ${error}") | ||
// Future.successful(None) | ||
// } | ||
// } else { | ||
// logger.warnWithTitle("social_blade_error", s"Error while calling Socialblade: ${response.code}") | ||
// Future.successful(None) | ||
// } | ||
// } | ||
|
||
println(response) | ||
|
||
response.body.toOption.pure[Future] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
# Path to your CSV file | ||
CSV_FILE="20240203_155429_checked.csv" | ||
|
||
# Path to the output file | ||
outputFile="$(date +"%Y%m%d_%H%M%S")_output.sql" | ||
|
||
# Ensure the output file is empty before starting to append data | ||
> "$outputFile" | ||
|
||
# Skip the header row and process each line | ||
tail -n +2 "$CSV_FILE" | while IFS=, read -r social_network name | ||
do | ||
# Generate a UUID for each row. Adjust based on your system's uuid generation command | ||
ID=$(uuidgen) | ||
|
||
# Capitalize the first letter of social_network using awk | ||
social_network=$(echo "$social_network" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}') | ||
|
||
# Print the INSERT statement and append to the output file | ||
echo "INSERT INTO influencers (id, social_network, name) VALUES ('$ID', '$social_network', '$name');" >> "$outputFile" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const https = require('https'); | ||
|
||
const options = { | ||
hostname: 'socialblade.com', | ||
path: '/youtube/user/carolinereceveur', | ||
method: 'GET', | ||
headers: { | ||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0', | ||
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', | ||
'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3', | ||
} | ||
}; | ||
|
||
const req = https.request(options, res => { | ||
console.log(`statusCode: ${res.statusCode}`); | ||
|
||
res.on('data', d => { | ||
process.stdout.write(d); | ||
}); | ||
}); | ||
|
||
req.on('error', error => { | ||
console.error(error); | ||
}); | ||
|
||
req.end(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
GET https://socialblade.com/youtube/user/carolinereceveur | ||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' | ||
### | ||
|
||
|
||
GET localhost:9000/api/certified-influencer?name=orang&socialNetwork=Facebook |