karlicoss / fbmessengerexport

Export/access you Messenger/Facebook chat messages
MIT License
66 stars 2 forks source link

Can't seem to get it to work at all #12

Open aluhrs13 opened 3 years ago

aluhrs13 commented 3 years ago

I can't seem to get it to work at all :(, could this be because I'm on Windows or some other user error?

Doing login

PS C:\Users\aluhr\source\repos\AndysQS\FBMessenger> python -m fbmessengerexport.export --login --cookies ANYSTRING
C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\exporthelpers\logging_helper.py:25: UserWarning: You might want to install 'logzero' for nice colored logs
  warnings.warn("You might want to install 'logzero' for nice colored logs")
email:<email>
password (won't be stored):<password>
Logging in <email>...
Attempt #1 failed, retrying
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 205, in login
    self._state = State.login(
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 151, in login
    return cls.from_session(session=session)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 188, in from_session
    fb_dtsg = FB_DTSG_REGEX.search(r.text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Trying with --cookies

PS C:\Users\aluhr\source\repos\AndysQS\FBMessenger> python -m fbmessengerexport.export --cookies '<cookie string>' --db C:\Users\aluhr\OneDrive\QS\Extracted\FBMessenger
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\aluhr\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\export.py", line 363, in <module>
    main()
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\export.py", line 286, in main
    run(cookies=params['cookies'], db=db)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\export.py", line 257, in run
    session_cookies=json.loads(cookies),
  File "C:\Users\aluhr\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\aluhr\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\aluhr\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

Trying with cookies in --secrets

PS C:\Users\aluhr\source\repos\AndysQS\FBMessenger> python -m fbmessengerexport.export --secrets secrets.py --db C:\Users\aluhr\OneDrive\QS\Extracted\FBMessenger
C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\exporthelpers\logging_helper.py:25: UserWarning: You might want to install 'logzero' for nice colored logs
  warnings.warn("You might want to install 'logzero' for nice colored logs")
Failed loading session
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 175, in setSession
    self._state = State.from_cookies(session_cookies, user_agent=user_agent)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 210, in from_cookies
    return cls.from_session(session=session)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 188, in from_session
    fb_dtsg = FB_DTSG_REGEX.search(r.text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
Logging in dummy_email...
Attempt #1 failed, retrying
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 205, in login
    self._state = State.login(
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 153, in login
    raise _exception.FBchatUserError(
fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/login/?email=dummy_email&li=_7FeYHbE1igg3kDxnbGh_sd4&e=1348028&shbl=1&refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr)
Attempt #2 failed, retrying
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 205, in login
    self._state = State.login(
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 153, in login
    raise _exception.FBchatUserError(
fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/login/?email=dummy_email&li=A7JeYCPCz8gfJAkBYLMDYj2e&e=1348028&shbl=1&refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr)
Attempt #3 failed, retrying
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 205, in login
    self._state = State.login(
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 153, in login
    raise _exception.FBchatUserError(
fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/login/?email=dummy_email&li=B7JeYEiWKYjHB1o9w1NUgfRx&e=1348028&shbl=1&refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr)
Attempt #4 failed, retrying
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 205, in login
    self._state = State.login(
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 153, in login
    raise _exception.FBchatUserError(
fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/login/?email=dummy_email&li=C7JeYMvfXlahaO4ZhcQjVnjV&e=1348028&shbl=1&refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr)
Traceback (most recent call last):
  File "C:\Users\aluhr\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\aluhr\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\export.py", line 363, in <module>
    main()
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\export.py", line 286, in main    run(cookies=params['cookies'], db=db)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbmessengerexport\export.py", line 252, in run
    client = Client(
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 103, in __init__
    self.login(email, password, max_tries, user_agent=user_agent)
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_client.py", line 205, in login
    self._state = State.login(
  File "C:\Users\aluhr\AppData\Roaming\Python\Python39\site-packages\fbchat\_state.py", line 153, in login
    raise _exception.FBchatUserError(
fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/login/?email=dummy_email&li=D7JeYLj-MefqOtnVY8kgsrxM&e=1348028&shbl=1&refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr)
karlicoss commented 3 years ago

Hi, yeah sorry about it -- the library I'm using seems unmaintained, so it's been broken for me as well :( Related issues are probably:

https://github.com/fbchat-dev/fbchat/issues/598 https://github.com/fbchat-dev/fbchat/issues/638

I might try to monkey-patch one of the hacks suggested there, but seems that they don't work for everyone

I added a warning about this to readme as well.

kennethbruskiewicz commented 2 years ago

@karlicoss There are two updates that got the thing to run for me:

karlicoss commented 2 years ago

@kennethbruskiewicz thanks for the follow up! How did you overwrite the revision? I can't find the line revision = int(r.text.split('"client_revision":', 1)[1].split(",", 1)[0]) which they reference here https://github.com/fbchat-dev/fbchat/issues/656#issue-1076365878

kennethbruskiewicz commented 2 years ago

It appears I'm using an older version with your project. The latest version renamed the file _state to _session.

The only line I'm seeing that might be equivalent to revision like the one above, is here: https://github.com/fbchat-dev/fbchat/blob/master/fbchat/_session.py#L431

jarekt commented 2 years ago

Found a well-working fork: https://github.com/MS-Jahan/fbchat (using this tool: https://github.com/techgaun/active-forks) A link to it in the readme might come in handy.

Stvad commented 1 year ago

Using a local install of the above fork worked for me

Stvad commented 1 year ago

or it did, but then it started crashing with the following

[D 221201 13:48:30 export:154] thread Blake Elias: fetched 0 starting from 1664084457391 (total 18)
--- Logging error ---
Traceback (most recent call last):
  File "/Users/vlad/Library/Python/3.10/lib/python/site-packages/logzero/__init__.py", line 215, in format
    message = record.getMessage()
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/logging/__init__.py", line 368, in getMessage
    msg = msg % self.args
  File "<attrs generated repr fbchat._user.User>", line 13, in __repr__
    return f'{self.__class__.__qualname__.rsplit(">.", 1)[-1]}(uid={self.uid!r}, type={self.type!r}, photo={self.photo!r}, name={self.name!r}, last_message_timestamp={self.last_message_timestamp!r}, message_count={self.message_count!r}, plan={self.plan!r}, url={self.url!r}, first_name={self.first_name!r}, last_name={self.last_name!r}, is_friend={self.is_friend!r}, gender={self.gender!r}, affinity={self.affinity!r}, nickname={self.nickname!r}, own_nickname={self.own_nickname!r}, color={self.color!r}, emoji={self.emoji!r})'
AttributeError: 'User' object has no attribute 'type'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/logging/__init__.py", line 1100, in emit
    msg = self.format(record)
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/logging/__init__.py", line 943, in format
    return fmt.format(record)
  File "/Users/vlad/Library/Python/3.10/lib/python/site-packages/logzero/__init__.py", line 236, in format
    record.message = "Bad message (%r): %r" % (e, record.__dict__)
  File "<attrs generated repr fbchat._user.User>", line 13, in __repr__
    return f'{self.__class__.__qualname__.rsplit(">.", 1)[-1]}(uid={self.uid!r}, type={self.type!r}, photo={self.photo!r}, name={self.name!r}, last_message_timestamp={self.last_message_timestamp!r}, message_count={self.message_count!r}, plan={self.plan!r}, url={self.url!r}, first_name={self.first_name!r}, last_name={self.last_name!r}, is_friend={self.is_friend!r}, gender={self.gender!r}, affinity={self.affinity!r}, nickname={self.nickname!r}, own_nickname={self.own_nickname!r}, color={self.color!r}, emoji={self.emoji!r})'
AttributeError: 'User' object has no attribute 'type'
Call stack:
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/vlad/Library/Python/3.10/lib/python/site-packages/fbmessengerexport/export.py", line 362, in <module>
    main()
  File "/Users/vlad/Library/Python/3.10/lib/python/site-packages/fbmessengerexport/export.py", line 285, in main
    run(cookies=params['cookies'], db=db)
  File "/Users/vlad/Library/Python/3.10/lib/python/site-packages/fbmessengerexport/export.py", line 263, in run
    errors = list(process_all(client=client, db=edb))
  File "/Users/vlad/Library/Python/3.10/lib/python/site-packages/fbmessengerexport/export.py", line 227, in process_all
    yield from error(r)
  File "/Users/vlad/Library/Python/3.10/lib/python/site-packages/fbmessengerexport/export.py", line 219, in error
    logger.error('While processing thread %s', thread)
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.
[E 221201 13:48:31 export:220] GraphQL error #None: A server error field_exception occured. Check server logs for details. / None
    NoneType: None

but that seems like a different problem 🤔