diff --git a/_already_sent/.gitkeep b/_already_sent/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/_already_sent/0cf7dedb7cfac4340056a612bc3c50b1.txt b/_already_sent/0cf7dedb7cfac4340056a612bc3c50b1.txt deleted file mode 100644 index a963820c..00000000 --- a/_already_sent/0cf7dedb7cfac4340056a612bc3c50b1.txt +++ /dev/null @@ -1 +0,0 @@ -https://www.openculture.com/2025/05/how-frank-lloyd-wrights-architecture-evolved-over-70-years-and-changed-america.html \ No newline at end of file diff --git a/_already_sent/12b2cc8c05f23758c6e812ef34044f53.txt b/_already_sent/12b2cc8c05f23758c6e812ef34044f53.txt deleted file mode 100644 index 83138f71..00000000 --- a/_already_sent/12b2cc8c05f23758c6e812ef34044f53.txt +++ /dev/null @@ -1 +0,0 @@ -https://en.wikipedia.org/wiki/Rainhill_trials \ No newline at end of file diff --git a/_already_sent/3f2721d52927f2d2c5f1146665b441dd.txt b/_already_sent/3f2721d52927f2d2c5f1146665b441dd.txt deleted file mode 100644 index e60c2b8a..00000000 --- a/_already_sent/3f2721d52927f2d2c5f1146665b441dd.txt +++ /dev/null @@ -1 +0,0 @@ -https://fossforce.com/2025/04/is-free-or-open-source-software-sustainable/ \ No newline at end of file diff --git a/_already_sent/8eef8d9550fb4952c4ef2ba2656b4038.txt b/_already_sent/8eef8d9550fb4952c4ef2ba2656b4038.txt deleted file mode 100644 index db0cfd4f..00000000 --- a/_already_sent/8eef8d9550fb4952c4ef2ba2656b4038.txt +++ /dev/null @@ -1 +0,0 @@ -https://manualdousuario.net/en/writing-chatgpt-ai/ \ No newline at end of file diff --git a/_already_sent/a3ffc5f64551046ad7132d159f1f40e7.txt b/_already_sent/a3ffc5f64551046ad7132d159f1f40e7.txt deleted file mode 100644 index 2e5d8665..00000000 --- a/_already_sent/a3ffc5f64551046ad7132d159f1f40e7.txt +++ /dev/null @@ -1 +0,0 @@ -https://goblackcat.com/feeling-exhausted/ \ No newline at end of file diff --git a/_already_sent/db41d26877002dfa9dba650122b8a298.txt b/_already_sent/db41d26877002dfa9dba650122b8a298.txt deleted file mode 100644 index 8b80b665..00000000 --- a/_already_sent/db41d26877002dfa9dba650122b8a298.txt +++ /dev/null @@ -1 +0,0 @@ -https://fenati.org.br/brasil-prepara-marco-regulatorio-para-data-centers-com-beneficios-fiscais-e-regras-sustentaveis/#datacenter \ No newline at end of file diff --git a/_credentials/.gitkeep b/_credentials/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/add_to_fedilist.php b/add_to_fedilist.php index 74a2b7d5..a9aff48a 100644 --- a/add_to_fedilist.php +++ b/add_to_fedilist.php @@ -1,31 +1,87 @@ $refreshSecondMargin) { + $minutes = floor($secondsLeft / 60); + $seconds = $secondsLeft % 60; + echo "⏳ Token expires in $minutes minutes and $seconds seconds.\n"; + } else { + echo "🔄 Access token expired or will expire in less than $refreshSecondMargin seconds. (Seconds Left: $secondsLeft). Refreshing...\n"; + + $refreshResponse = curlPost('https://oauth2.googleapis.com/token', [ + 'client_id' => $clientId, + 'client_secret' => $clientSecret, + 'refresh_token' => $token['refresh_token'], + 'grant_type' => 'refresh_token' + ]); + + if (isset($refreshResponse['access_token'])) { + $token['access_token'] = $refreshResponse['access_token']; + $token['expires_in'] = $refreshResponse['expires_in']; + $token['expires_at'] = time() + $refreshResponse['expires_in']; + file_put_contents($tokenPath, json_encode($token)); + echo "✅ Token refreshed.\n"; + } else { + echo "‼️ Failed to refresh token: " . ($refreshResponse['error'] ?? 'unknown') . "\n"; + return false; + } + } +} + + + // === Extract video ID === if (!preg_match('/(?:v=|\/)([a-zA-Z0-9_-]{11})/', $videoUrl, $matches)) { echo "⁉️ Invalid YouTube URL: $videoUrl\n"; return false; - } + } $videoId = $matches[1]; // === Step 1: Check if video is already in playlist === diff --git a/update_google_token.php b/update_google_token.php index f183070a..82ed8075 100755 --- a/update_google_token.php +++ b/update_google_token.php @@ -1,6 +1,8 @@ #!/usr/bin/php $clientId, @@ -109,22 +98,24 @@ while (true) { ]); if (isset($tokenResponse['access_token'])) { - $token = $tokenResponse; - echo "Saving token.json\n"; - file_put_contents(__DIR__ . '/_credentials/token.json', json_encode($token)); - break; + $tokenResponse['expires_at'] = time() + $tokenResponse['expires_in']; + $path = __DIR__ . '/_credentials/token.json'; + file_put_contents($path, json_encode($tokenResponse)); + echo "\n✅ Token saved as $path.\n"; + break; } + if (isset($tokenResponse['error']) && $tokenResponse['error'] !== 'authorization_pending') { - die("Auth error: " . $tokenResponse['error'] . "\n"); + die("\nAuth error: " . $tokenResponse['error'] . "\n"); } if (time() - $startTime > $deviceData['expires_in']) { - die("Authorization timed out.\n"); + die("\nAuthorization timed out.\n"); } } // === Step 3: Create FediList Playlist === -createPlaylist($token['access_token']); +createPlaylist($tokenResponse['access_token']); ?> diff --git a/utils.php b/utils.php new file mode 100644 index 00000000..39efbd04 --- /dev/null +++ b/utils.php @@ -0,0 +1,21 @@ +