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

The official instance is not operating anymore, as YouTube legal team requested me to do so #317

Open
Benjamin-Loison opened this issue Oct 12, 2024 · 22 comments
Labels
documentation Improvements or additions to documentation epic A task that is going to take more than a day to complete. high priority Issue disabling the user to use correctly the main features. incident official instance private instance For official private instances, hence is not about everyone's self-hosted ones.

Comments

@Benjamin-Loison
Copy link
Owner

See https://yt.lemnoslife.com.

@Benjamin-Loison Benjamin-Loison added the documentation Improvements or additions to documentation label Oct 12, 2024
@Benjamin-Loison Benjamin-Loison pinned this issue Oct 12, 2024
@Benjamin-Loison Benjamin-Loison changed the title The official instance is not operating anymore, as YouTube legal team requested me to do so The official instance is not operating anymore, as YouTube legal team requested Oct 12, 2024
@Benjamin-Loison Benjamin-Loison changed the title The official instance is not operating anymore, as YouTube legal team requested The official instance is not operating anymore, as YouTube legal team requested me to do so Oct 12, 2024
@Benjamin-Loison
Copy link
Owner Author

Could consider to some extent closing some no-key service related issues.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 12, 2024

We can keep no-key service related stuff as it can help rotate between regular project one and one with increase quota even if it is less useless which is maybe authorized by YouTube. Otherwise it can be helpful for people having multiple keys from different regular projects but this may not be authorized, see https://discord.com/channels/933841502155706418/933841503103627316/1231169992167526440 or even leaked ones.

Initially thought about doing these modifications:
diff --git a/addKey.php b/addKey.php
deleted file mode 100644
index 1bf6d46..0000000
--- a/addKey.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-    include_once 'common.php';
-
-    if (isset($_GET['key'])) {
-        $key = $_GET['key'];
-        // Regex-based filter.
-        if (isYouTubeDataAPIV3Key($key)) {
-            $keysContent = file_get_contents(KEYS_FILE);
-            $keys = explode("\n", $keysContent);
-            // Verify that the YouTube Data API v3 key isn't already stored by the instance.
-            if (!in_array($key, $keys)) {
-                $httpOptions = [
-                    'http' => [
-                        'ignore_errors' => true,
-                    ]
-                ];
-                $content = getJSON("https://www.googleapis.com/youtube/v3/videos?part=snippet&id=mWdFMNQBcjs&key=$key", $httpOptions, false);
-                // The force secret is used to store the YouTube Data API v3 even if it's not having quota, as we assume that the trusted instance that send it to this one has checked that it has quota.
-                if ($content['items'][0]['snippet']['title'] === 'A public video' || (isset($_GET['forceSecret']) && $_GET['forceSecret'] === ADD_KEY_FORCE_SECRET)) {
-                    file_put_contents(KEYS_FILE, ($keysContent === '' || $keysContent === false ? '' : "\n") . $key, FILE_APPEND);
-                    // Avoid sending another time the given key to all instances.
-                    if (!isset($_GET['forceSecret'])) {
-                        foreach (ADD_KEY_TO_INSTANCES as $addKeyToInstance) {
-                            getRemote($addKeyToInstance . "addKey.php?key=$key&forceSecret=" . ADD_KEY_FORCE_SECRET);
-                        }
-                    }
-                    echo 'YouTube Data API v3 key added.';
-                } elseif ($content['error']['errors'][0]['reason'] === 'quotaExceeded') {
-                    // As users can set `Queries per minute` quota to 0, we avoid denial-of-service by not considering them.
-                    echo 'Not adding YouTube Data API v3 key having quota exceeded.';
-                } else {
-                    // This YouTube Data API API v3 keys isn't assigned or there is another error.
-                    echo 'Incorrect YouTube Data API v3 key.';
-                }
-            } else {
-                echo 'This YouTube Data API v3 key is already in the list.';
-            }
-        } else {
-            echo "The key provided isn't a YouTube Data API v3 key.";
-        }
-    }
diff --git a/configuration.php b/configuration.php
index 58ae206..4d2db31 100644
--- a/configuration.php
+++ b/configuration.php
@@ -12,12 +12,4 @@
     define('HTTPS_PROXY_USERNAME', '');
     define('HTTPS_PROXY_PASSWORD', '');
 
-    // No-key endpoint:
-    define('KEYS_FILE', 'ytPrivate/keys.txt');
-    // Both following entries can be generated with `tr -dc A-Za-z0-9 </dev/urandom | head -c 32 ; echo`.
-    define('RESTRICT_USAGE_TO_KEY', '');
-    // If not defined, a random value will be used to prevent denial-of-service.
-    define('ADD_KEY_FORCE_SECRET', '');
-    define('ADD_KEY_TO_INSTANCES', []);
-
 ?>
diff --git a/index.php b/index.php
index b8e4e02..591aed6 100644
--- a/index.php
+++ b/index.php
@@ -248,38 +248,6 @@
 
 ?>
 
-<h2>Make <?php yt(); ?> request WITHOUT ANY KEY:</h2>
-
-<p>To make <strong>ANY <?php yt(); ?> request WITHOUT ANY KEY/USING YOUR QUOTA</strong>, you can use: <?php $noKey = 'noKey'; echo url(WEBSITE_URL . "$noKey/YOUR_REQUEST"); ?></p>
-<p>For instance you can use: <?php $example = 'videos?part=snippet&id=VIDEO_ID'; echo url(WEBSITE_URL . "$noKey/$example"); ?> instead of <?php echo url("https://www.googleapis.com/youtube/v3/$example"); ?></p>
-<p>I may add in the future limitation per IP etc if the quota need to be better shared among the persons using this API.</p>
-<?php
-
-    $keysCount = file_exists(KEYS_FILE) ? substr_count(file_get_contents(KEYS_FILE), "\n") + 1 : 0;
-
-?>
-<p>Currently this service is <a href='keys.php'>powered by <?php echo $keysCount; ?> keys</a>.</p>
-<script>
-
-function share() {
-    var xhttp = new XMLHttpRequest();
-    xhttp.onreadystatechange = function() {
-        if (this.readyState == 4 && this.status == 200) {
-            alert(xhttp.responseText);
-            youtubeDataAPIV3KeyInput.value = '';
-        }
-    };
-    var youtubeDataAPIV3KeyInput = document.getElementById('youtubeDataAPIV3Key');
-    const key = youtubeDataAPIV3KeyInput.value;
-    xhttp.open('GET', `addKey.php?key=${key}`);
-    xhttp.send();
-}
-
-</script>
-
-<?php $YOUTUBE_DATA_API_V3_KEY_LENGTH = 39; ?>
-Share your YouTube Data API v3 key to power the no-key service: <input type="text" id="youtubeDataAPIV3Key" placeholder="AIzaSy..." <?php printf('minlength="%s" maxlength="%s" size="%s"', $YOUTUBE_DATA_API_V3_KEY_LENGTH, $YOUTUBE_DATA_API_V3_KEY_LENGTH, $YOUTUBE_DATA_API_V3_KEY_LENGTH) ?>><button type="button" onClick="share()">share</button>
-
 <h2>Open-source:</h2>
 The source code is available on GitHub: <?php echo url('https://github.com/Benjamin-Loison/YouTube-operational-API'); ?>

As https://discord.com/channels/933841502155706418/933841503103627316/1294448943739961514 mentions using multiple instances.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 12, 2024

If everyone was fine with that removing https://yt.lemnoslife.com for just keeping the repository seems to make sense. Well .htaccess is still necessary for redirections. So instead of removing if everyone was fine with that could set a homepage redirecting the repository etc like https://ytdl-org.github.io/youtube-dl/.

curl -I https://yt.lemnoslife.com/matrix

helps.

I may would like to have a clever documentation generation to avoid committing with git an expanded algorithm result. Maybe GitHub page is an interesting alternative.

Benjamin-Loison added a commit that referenced this issue Oct 12, 2024
Verified exhaustiveness thanks to:

```bash
grep -r 'yt.lemnoslife.com'
```
@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 12, 2024

Should automate Oracle account creation with Online authentication API, then automate instance creation and setting up YouTube operational API instance.

IPv4=XXX.XXX.XXX.XXX
ssh ubuntu@$IPv4
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt dist-upgrade -y

sudo apt install -y apache2 php git
sudo a2enmod rewrite headers

# Replace `AllowOverride None` with `AllowOverride All` in `<Directory /var/www/>` in `/etc/apache2/apache2.conf`.

# Is not reload, enough?
sudo service apache2 restart

sudo chown -R www-data: /var/www/

sudo apt install -y composer protobuf-compiler

sudo su -l www-data -s /bin/bash
cd html/
rm index.html

git clone https://github.com/Benjamin-Loison/YouTube-operational-API .

composer require google/protobuf

protoc --php_out=proto/php/ --proto_path=proto/prototypes/ $(find proto/prototypes/ -type f)

The Server Fault answer 200658 or/and https://cloud.oracle.com/networking/vcns/ocid1.vcn.oc1.eu-marseille-1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/security-lists/ocid1.securitylist.oc1.eu-marseille-1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX?region=eu-marseille-1 are necessary to make curl http://XXX.XXX.XXX.XXX work fine.

Related to Benjamin_Loison/certbot/issues/4.

curl -s http://$IPv4 | grep 'This instance'
curl -s http://$IPv4/channels?handle=@MrBeast | jq .items[0].id
<br/><br/>This instance (my instance) uses version: <a href="https://github.com/Benjamin-Loison/YouTube-operational-API/commit/7e5798628d8a547199b18d91d9bbfd7006d16866
"UCX6OQ3DkcsbYNE6H8uQQuVA"

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 12, 2024

curl -s https://www.youtube.com | grep -Po 'AIzaSy[A-D][a-zA-Z0-9-_]{32}' | uniq
Output:
AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8
AIzaSyDZNkyC-AtROwMBpLfevIvqYk-Gfi8ZOeo
AIzaSyDophAQuyyiBr8h0nypEwXUKozH-BEswD0
AIzaSyBU2xE_JHvB6wag3tMfhxXpg2Q_W8xnM-I
AIzaSyDVDUqts7CooOWu_Yyc_8s4f8Ywc-Oj9H4
for line in `curl -s https://www.youtube.com | grep -Po 'AIzaSy[A-D][a-zA-Z0-9-_]{32}' | uniq`
do
    #echo "|$line|"
    echo $line
    curl "https://www.googleapis.com/youtube/v3/search?q=test&key=$line"
done
Output:
AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8
{
  "error": {
    "code": 403,
    "message": "YouTube Data API v3 has not been used in project 144809266352 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=144809266352 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "errors": [
      {
        "message": "YouTube Data API v3 has not been used in project 144809266352 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=144809266352 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
        "domain": "usageLimits",
        "reason": "accessNotConfigured",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=144809266352"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "youtube.googleapis.com",
          "consumer": "projects/144809266352"
        }
      }
    ]
  }
}
AIzaSyDZNkyC-AtROwMBpLfevIvqYk-Gfi8ZOeo
{
  "error": {
    "code": 403,
    "message": "Requests from referer \u003cempty\u003e are blocked.",
    "errors": [
      {
        "message": "Requests from referer \u003cempty\u003e are blocked.",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "youtube.googleapis.com",
          "consumer": "projects/929106728511"
        }
      }
    ]
  }
}
AIzaSyDophAQuyyiBr8h0nypEwXUKozH-BEswD0
{
  "error": {
    "code": 403,
    "message": "YouTube Data API v3 has not been used in project 512726152798 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=512726152798 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "errors": [
      {
        "message": "YouTube Data API v3 has not been used in project 512726152798 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=512726152798 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
        "domain": "usageLimits",
        "reason": "accessNotConfigured",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=512726152798"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/512726152798",
          "service": "youtube.googleapis.com"
        }
      }
    ]
  }
}
AIzaSyBU2xE_JHvB6wag3tMfhxXpg2Q_W8xnM-I
{
  "error": {
    "code": 403,
    "message": "YouTube Data API v3 has not been used in project 558586699847 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=558586699847 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "errors": [
      {
        "message": "YouTube Data API v3 has not been used in project 558586699847 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=558586699847 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
        "domain": "usageLimits",
        "reason": "accessNotConfigured",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=558586699847"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "youtube.googleapis.com",
          "consumer": "projects/558586699847"
        }
      }
    ]
  }
}
AIzaSyDVDUqts7CooOWu_Yyc_8s4f8Ywc-Oj9H4
{
  "error": {
    "code": 403,
    "message": "YouTube Data API v3 has not been used in project 209141348333 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=209141348333 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "errors": [
      {
        "message": "YouTube Data API v3 has not been used in project 209141348333 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=209141348333 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
        "domain": "usageLimits",
        "reason": "accessNotConfigured",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=209141348333"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "youtube.googleapis.com",
          "consumer": "projects/209141348333"
        }
      }
    ]
  }
}

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 12, 2024

So maybe with the right referrer AIzaSyDZNkyC-AtROwMBpLfevIvqYk-Gfi8ZOeo would be interesting.

DuckDuckGo and Google search "AIzaSyDZNkyC-AtROwMBpLfevIvqYk-Gfi8ZOeo" does not help.

node-ytpl/blob/ab62ca013de11b7a36ab159802c6fae15f00a477/test/pages/privatepage.html#L18 and similar results do not seem relevant.

https://www.joesandbox.com/analysis/1351525/1/html may be interesting.

@Benjamin-Loison
Copy link
Owner Author

@Benjamin-Loison
Copy link
Owner Author

Should consider potential unlimited quota, see https://discord.com/channels/933841502155706418/933841503103627316/1294441540156002315.

Related to #18.

@Benjamin-Loison
Copy link
Owner Author

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 12, 2024

#11#issuecomment-1325539722 specifies what account maybe to not use to act for the moment at least as a regular user.

Let us delete redundant projects on my main Google account using YouTube Data API v3, as it may be against ToS and 10,000 should be enough quota for my personal usage.

Related to Benjamin_Loison/youtube_push_notifications/issues/13.

@Benjamin-Loison Benjamin-Loison added incident official instance high priority Issue disabling the user to use correctly the main features. epic A task that is going to take more than a day to complete. private instance For official private instances, hence is not about everyone's self-hosted ones. labels Oct 15, 2024
@Benjamin-Loison
Copy link
Owner Author

Related to Webscrap_any_website/issues/39.

@Benjamin-Loison
Copy link
Owner Author

Related to Benjamin-Loison/gitea/issues/46.

@Benjamin-Loison
Copy link
Owner Author

@Benjamin-Loison
Copy link
Owner Author

Could add an anchor to my answer email but then should maybe change the table of contents organization, hence may break previous anchors, so let us not focus on that for the moment.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 25, 2024

#69 may have helped reduce HTTPS requests to YouTube servers, hence their detection of our usage.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 30, 2024

If you don't have a YouTube Data API v3 developer key:
If you already have a YouTube Data API v3 developer key:

It seems that if the former is not part of the table of contents it is because of ' but maybe for another reason.

regex.txt:
/^[ \t]*title\((\d), '([a-zA-Z0-9 -]+)'\);$/

https://www.php.net/manual/en/function.preg-quote.php

PHP script:
$regex = file_get_contents('regex.txt');
echo preg_quote($regex);
echo "\n";
echo preg_quote($regex, '/');
Output:
/\^\[ \\t\]\*title\\\(\(\\d\), '\(\[a\-zA\-Z0\-9 \-\]\+\)'\\\);\$/
\/\^\[ \\t\]\*title\\\(\(\\d\), '\(\[a\-zA\-Z0\-9 \-\]\+\)'\\\);\$\/

@Benjamin-Loison
Copy link
Owner Author

echo preg_quote("'");
'

@Benjamin-Loison
Copy link
Owner Author

tabtospaces does not seem to help, as well as [^\'].

@Benjamin-Loison
Copy link
Owner Author

<?php
    title(3, 'If you don\'t have a YouTube Data API v3 developer key');
?>
<?php
    title(3, 'If you already have a YouTube Data API v3 developer key');
?>

view-source: does not seem to help.

\ is maybe to blame.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 30, 2024

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Oct 30, 2024

    //$REGEX = '/^[ \t]*title\((\d), \'([^\']+)\'\);$/';
    //$REGEX = '/^[ \t]*title\((\d), \'(.+)\'\);$/';
    //$REGEX = '/^[ \t]*title\((\d), \'([a-zA-Z0-9\' -]+)\'\);$/';
    //$REGEX = '/^[ \t]*title\((\d), \'([a-zA-Z0-9\\\' -]+)\'\);$/';
    //$REGEX = '/\^\[ \\t\]\*title\\\(\(\\d\), \'\(\[a\-zA\-Z0\-9 \-\]\+\)\'\\\);\$/';

I solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation epic A task that is going to take more than a day to complete. high priority Issue disabling the user to use correctly the main features. incident official instance private instance For official private instances, hence is not about everyone's self-hosted ones.
Projects
None yet
Development

No branches or pull requests

1 participant