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

Error when parsing messages #57

Closed
miroslavtushev opened this issue Nov 1, 2017 · 22 comments
Closed

Error when parsing messages #57

miroslavtushev opened this issue Nov 1, 2017 · 22 comments

Comments

@miroslavtushev
Copy link

Traceback (most recent call last):                                               
  File "/Users/miroslav/anaconda3/bin/fbcap", line 11, in <module>
    sys.exit(fbcap())
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/fbchat_archive_parser/main.py", line 127, in fbcap
    write(fmt, fbch, directory or sys.stdout)
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/fbchat_archive_parser/writers/__init__.py", line 44, in write
    selected_writer().write(data, stream_or_dir)
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/fbchat_archive_parser/writers/writer.py", line 17, in write
    return self.write_history(data, stream)
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/fbchat_archive_parser/writers/text.py", 
line 19, in write_history
    ('-' * len(history.user)) + "-\n"
TypeError: object of type 'NoneType' has no len()

Happens every time regardless. Does anyone have any idea what's wrong?

@ownaginatious
Copy link
Owner

ownaginatious commented Nov 2, 2017

So it looks like the error is that your messages.htm file was somehow missing the user (a.k.a. your name). If you open the file, you should look something like this:

    ...
    <div class="contents">
        <h1>Your Name</h1>
        <p><a href="../messages/....html">Friend A</a></p>
        <p><a href="../messages/....html">Friend B</a></p>
        <p><a href="../messages/....html">Friend C</a></p>
        <p><a href="../messages/....html">Friend D</a></p>
        <p><a href="../messages/....html">Friend E</a></p>
    ...

The line of interest is the one with the <h1> tag.

Do you see something different?

@ownaginatious
Copy link
Owner

Oh, I think I know the error. It seems you tried to parse one of the HTML files under messages/. You should be parsing the messages.htm file.

├── html/
│   ├── ...
│   ├── messages.htm <- Parse me!
├── messages/
│   ├── 1043...html
│   ├── ...

@miroslavtushev
Copy link
Author

Oops, my bad

@miroslavtushev
Copy link
Author

Ok, now I'm getting something different

Unable to locate the referenced chat file "/Users/miroslav/Downloads/facebook/html/sages/338103939874843.html". Please ensure that your "messages.htm" file is relative to your "messages/" directory in the following way while parsing:

    ├── html/
    │   ├── ...
    │   ├── messages.htm
    ├── messages/

Although if I open messages.htm via a browser and try to navigate to my messages - it works, no broken links.

@ownaginatious
Copy link
Owner

Hmm, I think I may have made some assumptions about how the messages.htm file is formatted that aren't always true. What do the <a> tags look like in your messages.htm file? Do they look like this?

<p><a href="../messages/<some long number>.html">Friend A</a></p>

Or like this?

<p><a href="messages/<some long number>.html">Friend A</a></p>

@miroslavtushev
Copy link
Author

@ownaginatious

</h1><p><a href="messages/338103939874843.html">Friend A </a></p><p>

@ownaginatious
Copy link
Owner

Hmm, odd. I just downloaded my data again and it looks like Facebook broke the relative path...

Anyway, I fixed it to be compatible with that format and the old format (should they ever try to fix it...). Please try the latest version: 1.1.post6

@miroslavtushev
Copy link
Author

sorry, still the same error...

@ownaginatious
Copy link
Owner

Did you do pip install --upgrade fbchat-archive-parser?

@miroslavtushev
Copy link
Author

miroslavtushev commented Nov 3, 2017

Yes. Does the code work for you?

@ownaginatious
Copy link
Owner

Can you post a stack trace?

@ownaginatious
Copy link
Owner

Yeah, it works for me. If you could post the error output, I could at least see which directory it's trying to look in :/

@miroslavtushev
Copy link
Author

miroslavtushev commented Nov 3, 2017

Traceback (most recent call last):
  File "/Users/miroslav/anaconda3/lib/python3.6/site-packages/fbchat_archive_parser/parser.py", line 433, in process_thread
    with io.open(file_path, 'rt', encoding='utf8') as thread_file:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/miroslav/Downloads/facebook-miroslav/html/messages/338103939874843.html'

Unable to locate the referenced chat file "/Users/miroslav/Downloads/facebook-miroslav/html/messages/338103939874843.html". Please ensure that your "messages.htm" file is relative to your "messages/" directory in the following way while parsing:

    ├── html/
    │   ├── ...
    │   ├── messages.htm
    ├── messages/

Not sure if that's the full stack, that's the only message I could get

@ownaginatious
Copy link
Owner

ownaginatious commented Nov 3, 2017

Well, only thing I can think of at this point is that the implementation of some of the Python os library functions work differently on your computer than mine. I tried switching to something that should be more reliable. Hopefully it'll work now: 1.1.post7

@miroslavtushev
Copy link
Author

Works like a charm now, many many thanks to you for guiding me thru this process!!!

@ownaginatious
Copy link
Owner

Great, I'm glad that fixed it! :D

@eldenvo
Copy link

eldenvo commented Nov 7, 2017

Hi there, I'm definitely using 1.1.post7 and I'm also getting the same thing:

Unable to locate the referenced chat file "messages/997041420387057.html". Please ensure that your "messages.htm" file is relative to your "messages/" directory in the following way while parsing:
├── html/
│   ├── ...
│   ├── messages.htm
├── messages/

@ownaginatious
Copy link
Owner

Which OS are you using?

@eldenvo
Copy link

eldenvo commented Nov 7, 2017

Windows 10

@ownaginatious
Copy link
Owner

Hmm, it’s probably an issue with how the tool uses Python file system tools and Windows paths. This tool is unfortunately not well tested with Windows. I will look into it soon (gotta get a Windows VM running first).

@eldenvo
Copy link

eldenvo commented Nov 7, 2017

No problem and thanks for your work - it has generally worked fine for me up until this change in structure!

@ownaginatious
Copy link
Owner

^ should be fixed now in 1.1.post8 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants