hfaran / slack-export-viewer

A Slack Export archive viewer that allows you to easily view and share your Slack team's export
https://pypi.python.org/pypi/slack-export-viewer
MIT License
939 stars 194 forks source link

IndexError: list index out of range #63

Closed accuratefeed closed 6 years ago

accuratefeed commented 6 years ago

I saw #24 and I thought this issue was fixed. I'm getting the following error:

`PS C:\Users\AccurateFeed\downloads> slack-export-viewer --archive ldrs.zip ldrs.zip extracting to C:\Users\AccurateFeed\AppData\Local\Temp\2_slackviewer\5e226d974f1b15de666dab44c8ea52f329d39587... ldrs.zip extracted to C:\Users\AccurateFeed\AppData\Local\Temp\2_slackviewer\5e226d974f1b15de666dab44c8ea52f329d39587.

tscritch commented 6 years ago

Hey @accuratefeed can you add your channels.json file or a snippet of it. The only reason I can see this happening is because there are no channels at all. But if that's not the case I can test with your data. Thanks!

accuratefeed commented 6 years ago

Hi @tscritch thanks for replying so quickly. The channels.json file is indeed empty. I contacted slack about this and they're not sure why it's empty either. I do have the folder of the channel I'm trying to view though and the other json files such as users.json has data in it. I'm really just trying to put this 1 channel in a viewable format, so if you have any other suggestions, please let me know!

tscritch commented 6 years ago

Wow. Interesting! haha Well the list of channels is created from that channels.json so we need it... I would suggest for now just manually creating the file. Go to the tests folder in this project and open the zip to find the channels.json and just copy one from there. I'm not sure what else you could do if you don't have data in that file.

accuratefeed commented 6 years ago

@tscritch I was able to find a channels.json with data in it. Now I'm getting the following error:

PS C:\Users\AccurateFeed\downloads> slack-export-viewer --archive ldrs.zip ldrs.zip extracting to C:\Users\AccurateFeed\AppData\Local\Temp\2\_slackviewer\25cc1dfe34b348f9bc8e83888e92fcff8f708853... ldrs.zip extracted to C:\Users\AccurateFeed\AppData\Local\Temp\2\_slackviewer\25cc1dfe34b348f9bc8e83888e92fcff8f708853. Traceback (most recent call last): File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\AccurateFeed\AppData\Local\Programs\Python\Python36-32\Scripts\slack-export-viewer.exe\__main__.py", line 9, in <module> File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 722, in __call__ return self.main(*args, **kwargs) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 697, in main rv = self.invoke(ctx) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 535, in invoke return callback(*args, **kwargs) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\main.py", line 76, in main configure_app(app, archive, debug) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\main.py", line 41, in configure_app groups = compile_groups(path, user_data, group_data) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\archive.py", line 67, in compile_groups day_messages = json.load(f) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\json\__init__.py", line 296, in load return loads(fp.read(), File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 428: character maps to <undefined>

tscritch commented 6 years ago

Ah jeez haha it looks like that would be a character it can't read for some reason... I'm not too experienced with that stuff. @hfaran any insight?

accuratefeed commented 6 years ago

I was able to get what I needed using levelsio's script, which I believe this script was based off of. Any idea if hfaran's script is using utf8 or latin1 to decode? Just curious.

tscritch commented 6 years ago

Ok great. It is using utf8 👍

hfaran commented 6 years ago

@tscritch Looking at the stack trace that @accuratefeed posted, the bug is here: https://github.com/hfaran/slack-export-viewer/blob/5d9608d3945aa822bced0139477c811c4f8c9ab9/slackviewer/reader.py#L145-L147

You're missing the encoding="utf8" argument on io.open

hfaran commented 6 years ago

Committed the fix, but I'm gonna wait until your next PR goes to make a new release

hfaran commented 6 years ago

Actually, I went ahead and released 0.6.0. @accuratefeed please try it