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

[Twitter] "Following" extractor breaks when you are subscribed to the platform-banned user #2020

Closed
oxi7589 opened this issue Nov 13, 2021 · 2 comments

Comments

@oxi7589
Copy link

oxi7589 commented Nov 13, 2021

TwitterFollowingExtractor returns an empty list of users for accounts whose following list contains someone who is banned from platform. In most cases the offending account just disappears from the list, but it looks like in some cases it lingers on for longer. My assumption is that this happens when the "almost banned" account is appealing the ban decision.

(venv) PS> python .\gallery_dl\ -j --limit 1 --cookies cookies-twitter-com.txt https://twitter.com/[MyScreenName]/following
[]

GraphQL response contains the following error, but otherwise is complete and perfectly usable, at least for my purposes:

(HTTP 200 OK)

{
  "errors": [
    {
      "message": "_Missing: User not found.",
      "locations": [
        {
          "line": 707,
          "column": 3
        }
      ],
      "path": [
        "user",
        "following_timeline",
        "timeline",
        "instructions",
        2,
        "entries",
        88,
        "content",
        "itemContent",
        "user",
        "legacy"
      ],
      "extensions": {
        "name": "GenericError",
        "source": "Server",
        "code": 50,
        "kind": "NonFatal",
        "tracing": {
          "trace_id": "8d90565bf6d18343"
        }
      },
      "code": 50,
      "kind": "NonFatal",
      "name": "GenericError",
      "source": "Server",
      "tracing": {
        "trace_id": "8d90565bf6d18343"
      }
    }
  ],
  "data": {
    (normal response continues here)
  }

The data[] element for the "almost banned" user looks like this:

[
  6,
  "https://twitter.com/i/user/1288019650152824832",
  {
    "id": "VXNlcjoxMjg4MDE5NjUwMTUyODI0ODMy",
    "rest_id": "1288019650152824832"
  }
],

i.e. it has no "legacy" section. Note that when this user did have their own screen name, it was not "_Missing".

The problem with that is that TwitterAPI()._call() raises exception when it sees non-empty errors list and a status code of 200. I was able to successfully extract my following list by commenting out these two lines:

            # if msg and response.status_code < 400:
            #     raise exception.StopExtraction(msg)

but this probably affects other parts of the Twitter-related code in a negative way since this is not only used for the "following" thing.

I am thus seeking help from the gallery-dl maintainers to come up with a solution that fixes the "following" extractor without breaking anything else in the process.

mikf added a commit that referenced this issue Nov 15, 2021
only show a warning for nonfatal errors
and do not raise a StopExtraction exception
@mikf
Copy link
Owner

mikf commented Nov 15, 2021

Should be fixed with 4377f1c by not treating these errors as fatal and only printing a warning instead. I wasn't able to test this on a live example myself, so please let me know if it actually does what it is supposed to.

@oxi7589
Copy link
Author

oxi7589 commented Nov 16, 2021

Sadly the twitter that was causing the problem has since been banned for good as is no longer returned by the "following" API. Reproducing this problem artificially is too tricky, as if the account is removed voluntarily by its owner it doesn't happen. I did, however, manage to do some testing by hacking gallery-dl to use my saved .json responses from when it was happening, and that has worked as expected.

@mikf mikf closed this as completed Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants