Code Monkey home page Code Monkey logo

slack-export-viewer's Introduction

Slack Export Viewer

CI PyPI version

A Slack Export archive viewer that allows you to easily view and share your Slack team's export (instead of having to dive into hundreds of JSON files).

Preview

Contents

Overview

slack-export-viewer is useful for small teams on a free Slack plan (limited to 10,000 messages) who overrun their budget and ocassionally need a nice interface to refer back to previous messages. You get a web interface to easily scroll through all channels in the export without having to look at individual JSON files per channel per day.

slack-export-viewer can be used locally on one machine for yourself to explore an export, it can be run on a headless server (as it is a Flask web app) if you also want to serve the content to the rest of your team, or it can output HTML for deploying a static website.

Installation

I recommend pipx for a nice isolated install.

pipx install slack-export-viewer

Or just feel free to use pip as you like.

pip install slack-export-viewer

slack-export-viewer will be installed as an entry-point; run from anywhere.

$ slack-export-viewer --help
Usage: slack-export-viewer [OPTIONS]

Options:
  -p, --port INTEGER        Host port to serve your content on
  -z, --archive PATH        Path to your Slack export archive (.zip file or
                            directory)  [required]
  -I, --ip TEXT             Host IP to serve your content on
  --no-browser              If you do not want a browser to open
                            automatically, set this.
  --channels TEXT           A comma separated list of channels to parse.
  --no-sidebar              Removes the sidebar.
  --no-external-references  Removes all references to external css/js/images.
  --test                    Runs in 'test' mode, i.e., this will do an archive
                            extract, but will not start the server, and
                            immediately quit.
  --debug
  --html-only               If you want static HTML only.
  -o, --output-dir PATH     Output directory for static HTML. [default: `html_output`]   
  --help                    Show this message and exit.

Usage

1) Grab your Slack team's export

2) Point slack-export-viewer to it

Point slack-export-viewer to the .zip file and let it do its magic

slack-export-viewer -z /path/to/export/zip

If everything went well, your archive will have been extracted and processed, and a browser window will have opened showing your #general channel from the export. Or, if the html-only flag was set, HTML files will be available in the html-output directory (or a different directory if specified).

CLI

There is now a CLI included as well. Currently the one command you can use is clearing the cache from slack-export-viewer from your %TEMP% directory; see usage:

└———→ slack-export-viewer-cli --help
Usage: slack-export-viewer-cli [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  clean  Cleans up any temporary files (including...

Examples

┌— hamza@AURORAONE C:\Users\hamza
└———→ slack-export-viewer-cli clean
Run with -w to remove C:\Users\hamza\AppData\Local\Temp\_slackviewer
┌— hamza@AURORAONE C:\Users\hamza
└———→ slack-export-viewer-cli clean -w
Removing C:\Users\hamza\AppData\Local\Temp\_slackviewer...

Local Development

After installing the requirements in requirements.txt and dev-requirements.txt, define FLASK_APP as main and select any channels desired from an export:

export FLASK_APP=main && export SEV_CHANNELS=general

Start a development server by running app.py in the root directory:

python3 app.py -z /Absolute/path/to/archive.zip --debug

Acknowledgements

Credit to Pieter Levels whose blog post and PHP script I used as a jumping off point for this.

Improvements over Pieter's script

slack-export-viewer is similar in core functionality but adds several things on top to make it nicer to use:

  • An installable application
  • Automated archive extraction and retention
  • A Slack-like sidebar that lets you switch channels easily
  • Much more "sophisticated" rendering of messages
  • A Flask server which lets you serve the archive contents as opposed to a PHP script which does static file generation

slack-export-viewer's People

Contributors

anonymousdouble avatar barnstws avatar benwarfield-usds avatar brucehvn avatar cuongtransc avatar dvii7 avatar gitname avatar greymd avatar hargup avatar hfaran avatar jasonrwang avatar jonpas avatar karlding avatar keirospl avatar lethosor avatar limwz01 avatar lsmith77 avatar merobi-hub avatar mikejgray avatar miraihattori avatar mrmarkhayward avatar muratdoganer avatar nindanaoto avatar rileymichael avatar rusq avatar thomasvandoren avatar timbaileyjones avatar tjanez avatar tscritch avatar waderobson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-export-viewer's Issues

Download pictures

Hi

As far as I see, slack-export-viewer does not create code to see pictures on the local page, it renders only a link to the slack url of the picture, doesn't it?
Indeed, it would be nice to have slack-export-viewer be able to download pictures in a local folder.
Any chance to see a improved code (which is already indeed very useful, but could be even more useful)
Thanks Cheers
mario

Mistake In Messages.CS CreateSlackMessageHtmlArchiveFile

Good day,

First off thank you very much for this it helped my tremendously.

I found a small mistake in your code in the procedure: static void CreateSlackMessageHtmlArchiveFile the write to HTML was taking the first 250 lines every time instead of being incremented with messageIndexPosition.

Also the HTML file being produced did not have any CR LF in the file causing it to become unmanageable "wide".

StringBuilder fileBody =new StringBuilder();
fileBody.Append("");
for (int i = messageIndexPosition; i < messageIndexPosition + numOfMessagesToTake; i++)
{
var messageAsHtml = MessageToHtml(messageList[i], channelsMapping);
fileBody.AppendLine(messageAsHtml);
}
fileBody.AppendLine("");
messageIndexPosition += numOfMessagesToTake;
w.WriteLine(fileBody);

Printable export

This is more of an offer than a request: I recently used slack-export-viewer to produce a printable single-file extract of an entire workspace, for archival purposes. This involved some feature additions and bug fixes, which I've either submitted or am preparing to submit, but also some additional work to produce a command-line script that generates a (mammoth) HTML file that I can then turn into PDF and be confident nobody will come back to me in a month or six asking "how do I open this file?"

If that would be an acceptable contribution, I'll clean it up and make a pull request: since it's a little outside the original scope of the project, though, I'd totally understand not wanting it to get into the main codebase.

Encoding issue

[EDITED]
We have a Slack team with a unicode character in its name. We get the following error. Changing the name of the slack archive fixes it.

C:\SomeFolder> slack-export-viewer -z "archive_name_with_the_chacarcetr_ç.zip"
Traceback (most recent call last):
  File "c:\development\secondlife\python278\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\development\secondlife\python278\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Development\SecondLife\Python278\Scripts\slack-export-viewer.exe\__main__.py", line 9, in <module>
  File "c:\development\secondlife\python278\lib\site-packages\click\core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "c:\development\secondlife\python278\lib\site-packages\click\core.py", line 696, in main
    rv = self.invoke(ctx)
  File "c:\development\secondlife\python278\lib\site-packages\click\core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\development\secondlife\python278\lib\site-packages\click\core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "c:\development\secondlife\python278\lib\site-packages\slackviewer\main.py", line 60, in main
    configure_app(app, archive, debug)
  File "c:\development\secondlife\python278\lib\site-packages\slackviewer\main.py", line 34, in configure_app
    path = extract_archive(archive)
  File "c:\development\secondlife\python278\lib\site-packages\slackviewer\archive.py", line 59, in extract_archive
    extracted_path))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xc7' in position 12: ordinal not in range(128)

500 Internal Server Error / TypeError

Hello, I am attempting to use this on a Mac. I get a TypeError: '<' not supported between instances of 'dict' and 'dict'

Not sure if I'm doing something wrong, but here's my output:

/Users/obels/git/export.zip extracting to /var/folders/js/27tl2yc17wdfrh3_mb1647zc0000gp/T/_slackviewer/512eebdb2f56e8d873381d389a80e5258d264634...
/Users/obels/git/export.zip extracted to /var/folders/js/27tl2yc17wdfrh3_mb1647zc0000gp/T/_slackviewer/512eebdb2f56e8d873381d389a80e5258d264634.
 * Running on http://localhost:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [09/Jul/2018 15:33:50] "GET / HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "/Users/obels/anaconda/lib/python3.6/site-packages/werkzeug/serving.py", line 209, in run_wsgi
    execute(self.server.app)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/werkzeug/serving.py", line 197, in execute
    application_iter = app(environ, start_response)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/obels/anaconda/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/obels/anaconda/lib/python3.6/site-packages/slackviewer/app.py", line 79, in index
    return channel_name("general")
  File "/Users/obels/anaconda/lib/python3.6/site-packages/slackviewer/app.py", line 23, in channel_name
    dm_users=sorted(dm_users),
TypeError: '<' not supported between instances of 'dict' and 'dict'

error with compile_dm_users

Exported today cannot get this to work from zip

running

sudo slack-export-viewer -z /Users/<usr>/Downloads/<domain>\ Slack\ export\ Apr\ 2\ 2018.zip

errors

Traceback (most recent call last):
  File "/usr/local/bin/slack-export-viewer", line 9, in <module>
    load_entry_point('slack-export-viewer==0.4.2', 'console_scripts', 'slack-export-viewer')()
  File "/Library/Python/2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 76, in main
    configure_app(app, archive, debug)
  File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 43, in configure_app
    dm_users = compile_dm_users(path, user_data, dm_data, empty_dms)
  File "/Library/Python/2.7/site-packages/slackviewer/archive.py", line 98, in compile_dm_users
    user2 = user_data[dm["members"][1]]
KeyError: u'U7E7Z0YTB'

extracted archives not working

I'm trying to use the --archive option to read a directory instead of a zip file but it doesn't work. I've tried a few variations to the path spec like ./slackarchives and /code/slackarchives and /code/slackarchives/ to no avail.

# slack-export-viewer --archive ./slackarchives/
Traceback (most recent call last):
  File "/usr/local/bin/slack-export-viewer", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/slackviewer/main.py", line 60, in main
    configure_app(app, archive, debug)
  File "/usr/local/lib/python3.6/site-packages/slackviewer/main.py", line 34, in configure_app
    path = extract_archive(archive)
  File "/usr/local/lib/python3.6/site-packages/slackviewer/archive.py", line 49, in extract_archive
    raise TypeError("{} is not a zipfile".format(filepath))
TypeError: /slackarchives/ is not a zipfile

This seems to be a problem with https://github.com/hfaran/slack-export-viewer/blob/0.2.0/slackviewer/archive.py#L47. I might eventually get around to fixing this once I need to merge multiple slack exports.

Python 3.5

I made one slight change to this most excellent tool to get it running with python 3.5. I'm no python dev so I'm simply applying a fix suggested on a forum:

In app.py change both occurrences of this line to wrap keys() as a list:

channels = list(flask._app_ctx_stack.channels.keys())

which solves a failure on startup:

TypeError: 'dict_keys' object does not support indexing

after that it worked perfectly.

In the startup script slack-export-viewer the first line is then

!/usr/local/opt/python3/bin/python3.5

Unrelated to this issue, while I'm here, time permitting I'd like to look at extending with full cross channel search. Interested to hear from anyone else interested in this.

UnicodeDecodeError

I have been able to run other Slack exports up until today.

I get this in the traceback. Any help is appreciated.

Traceback (most recent call last):
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\Scripts\slack-export-viewer-script.py", line 11, in
load_entry_point('slack-export-viewer==0.2.0', 'console_scripts', 'slack-export-viewer')()
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 722, in call
return self.main(*args, **kwargs)
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\site-packages\slack_export_viewer-0.2.0-py3.6.egg\slackviewer\main.py", line 60, in main
configure_app(app, archive, debug)
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\site-packages\slack_export_viewer-0.2.0-py3.6.egg\slackviewer\main.py", line 37, in configure_app
channels = compile_channels(path, user_data, channel_data)
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\site-packages\slack_export_viewer-0.2.0-py3.6.egg\slackviewer\archive.py", line 24, in compile_channels
day_messages = json.load(f)
File "C:\Users\bpenney\AppData\Local\Programs\Python\Python36-32\lib\json_init_.py", line 296, in load
return loads(fp.read(),
File "C:\Users\bpenney\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 0x81 in position 9003: character maps to

IndexError: list index out of range

From @ottominggu

C:\>slack-export-viewer -z f:/Slackchat/hita.zip
/tmp\_slackviewer\2eb3aac8e2200c59495898f693f1a2752d946d34 already exists
 * Running on http://localhost:5000/ (Press CTRL+C to quit)
ERROR:root:A channel reference was detected but metadata not found in channels.json: u'C0AK0LRFX'
ERROR:root:A channel reference was detected but metadata not found in channels.json: u'C0AK0LRFX'
ERROR:root:A channel reference was detected but metadata not found in channels.json: u'C0AMH9V26'
ERROR:root:A channel reference was detected but metadata not found in channels.json: u'C0AMH9V26'
ERROR:root:A channel reference was detected but metadata not found in channels.json: u'C0BS45DBJ'
ERROR:root:A channel reference was detected but metadata not found in channels.json: u'C0BS45DBJ'
127.0.0.1 - - [30/Apr/2016 13:10:50] "GET / HTTP/1.1" 500 -
INFO:werkzeug:127.0.0.1 - - [30/Apr/2016 13:10:50] "GET / HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\werkzeug\serving.py", line 193, in run_wsgi
    execute(self.server.app)
  File "c:\python27\lib\site-packages\werkzeug\serving.py", line 181, in execute
    application_iter = app(environ, start_response)
  File "c:\python27\lib\site-packages\flask\app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "c:\python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "c:\python27\lib\site-packages\flask\app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "c:\python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "c:\python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "c:\python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "c:\python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "c:\python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "c:\python27\lib\site-packages\slackviewer\app.py", line 24, in index
    return channel_name("general")
  File "c:\python27\lib\site-packages\slackviewer\app.py", line 17, in channel_name
    channels=sorted(channels))
  File "c:\python27\lib\site-packages\flask\templating.py", line 128, in render_template
    context, ctx.app)
  File "c:\python27\lib\site-packages\flask\templating.py", line 110, in _render
    rv = template.render(context)
  File "c:\python27\lib\site-packages\jinja2\environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "c:\python27\lib\site-packages\jinja2\environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "c:\python27\lib\site-packages\slackviewer\templates\viewer.html", line 34, in top-level template code
    <div class="msg">{{ message.msg|safe }}</div>
  File "c:\python27\lib\site-packages\jinja2\environment.py", line 408, in getattr
    return getattr(obj, attribute)
  File "c:\python27\lib\site-packages\slackviewer\message.py", line 71, in msg
    if not message[0].strip():
IndexError: list index out of range

No such file or directory in tmp/_slackviewer

I get an error upon processing the zip file. I am running OS X El Capitan. (I am very new to programing so I might be doing something wrong.)

10:~ TFranke$ slack-export-viewer -z /Users/TFranke/Downloads/Own-CL1.zip
/Users/TFranke/Downloads/Own-CL1.zip extracting to /tmp/_slackviewer/6775c84e42014a2a909e09769a2d07e86947f81a...
/Users/TFranke/Downloads/Own-CL1.zip extracted to /tmp/_slackviewer/6775c84e42014a2a909e09769a2d07e86947f81a.
Traceback (most recent call last):
File "/Users/TFranke/.local/bin/slack-export-viewer", line 11, in
sys.exit(main())
File "/Users/TFranke/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/click/core.py", line 716, in call
return self.main(*args, **kwargs)
File "/Users/TFranke/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/Users/TFranke/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/TFranke/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/Users/TFranke/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/slackviewer/main.py", line 60, in main
configure_app(app, archive, debug)
File "/Users/TFranke/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/slackviewer/main.py", line 35, in configure_app
user_data = get_users(path)
File "/Users/TFranke/.local/venvs/slack-export-viewer/lib/python2.7/site-packages/slackviewer/archive.py", line 31, in get_users
with open(os.path.join(path, "users.json")) as f:
IOError: [Errno 2] No such file or directory: '/tmp/_slackviewer/6775c84e42014a2a909e09769a2d07e86947f81a/users.json'
10:~ TFranke$

This is the zip file:
Own-CL1.zip

Best method to run in production

Hi there! :)

Thanks again for building this! I have a few additional questions about running it in production; in particular, I'm using WebFaction as my host, and have set up a mod_wsgi 4.5.7/Python 2.7 app.

I'm attempting to run it with: slack-export-viewer -z CMWW\ export\ Nov\ 29\ 2016.zip -p 5000 --no-browser but presently I only see this output when I load the URL in the browser:

Welcome to your mod_wsgi website! It uses:

Python 2.7.12 (default, Sep  2 2016, 21:43:20) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)]
WSGI version: (4, 5, 7)

Any thoughts?

Error on request?

Hi, when I try to run slack-export-viewer I get the following error:

root@dev:/var/home/abeveridge/slack-history# slack-export-viewer -p 54321 -z slack-export-26.04.2016-14.47.zip
slack-export-26.04.2016-14.47.zip extracting to /tmp/_slackviewer/ffcc65ff4a2926970c0e5c95d9acdd973019e106...
slack-export-26.04.2016-14.47.zip extracted to /tmp/_slackviewer/ffcc65ff4a2926970c0e5c95d9acdd973019e106.
 * Running on http://localhost:54321/ (Press CTRL+C to quit)
127.0.0.1 - - [26/Apr/2016 15:11:11] "GET / HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 193, in run_wsgi
    execute(self.server.app)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 181, in execute
    application_iter = app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/app.py", line 24, in index
    return channel_name("general")
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/app.py", line 17, in channel_name
    channels=sorted(channels))
  File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 128, in render_template
    context, ctx.app)
  File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 110, in _render
    rv = template.render(context)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/templates/viewer.html", line 34, in top-level template code
    <div class="msg">{{ message.msg|safe }}</div>
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 408, in getattr
    return getattr(obj, attribute)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/message.py", line 52, in msg
    text = self._render_text(text)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/message.py", line 105, in _render_text
    message = re.sub(r"<#C0\w+>", self._sub_channel_ref, message)
  File "/usr/lib/python2.7/re.py", line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/message.py", line 183, in _sub_channel_ref
    channel_name = self.__CHANNEL_DATA[channel_id]["name"]
KeyError: u'C0VGDB8P4'

Any suggestions?

Thanks!

entry point on windows is fake news

slack-export-viewer will be installed as an entry-point; run from anywhere.

doesn't work
#makeslackviewergreatagain

also running from hand, by starting the mainscript on the command prompt doesn't work and doesn't give any errors....

Installing on WebFaction

Hi there!

I'm trying to get this hosted on WebFaction so I can share the archive viewer with my team, but am running into the following problem. Is there a way I can fork the viewer to not use the local Python 2.6, if that's the problem?

Traceback (most recent call last):
  File "/home/apiq/bin/slack-export-viewer", line 7, in <module>
    from slackviewer.main import main
  File "/home/apiq/lib/python2.6/slackviewer/main.py", line 8, in <module>
    from slackviewer.archive import \
  File "/home/apiq/lib/python2.6/slackviewer/archive.py", line 32
    return {u["id"]: u for u in json.load(f)}
                         ^
SyntaxError: invalid syntax

Export viewer compatibility with slack-auto-export

I wanted to combine slack-auto-export with this viewer and slack2html to automate the process of exporting a public slack workspace to static html for archival as a git repo, ie. without the need to manually download .zip histories from slack. To do this, I just had to tweak a few lines in both repos. My forks are here, in case they are useful to anyone else -
slack-auto-export - given a token and output directory, generates JSON output suitable for my fork of:
slack-export-viewer - takes above directory and does what the original viewer does

Changes to the latter break ability to take downloaded zip (or extracted zip) as input, but if there is interest, I guess the two could be merged together to handle data from either source.

This may be of interest/relevant to others with similar needs, eg. #43

IndexError: list index out of range

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.

  • Serving Flask app "slackviewer.app" (lazy loading)
  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://localhost:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [02/May/2018 09:10:57] "GET / HTTP/1.1" 500 -
    Error on request:
    Traceback (most recent call last):
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\werkzeug\serving.py", line 270, in run_wsgi
    execute(self.server.app)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\werkzeug\serving.py", line 258, in execute
    application_iter = app(environ, start_response)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 2309, in call return self.wsgi_app(environ, start_response)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 2295, in wsgi_app response = self.handle_exception(e)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask_compat.py", line 35, in reraise
    raise value
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request()
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask_compat.py", line 35, in reraise
    raise value
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.view_functionsrule.endpoint
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\app.py", line 81, in index
    return channel_name(channels[0])
    IndexError: list index out of range`

"This site can't be reached"

pip install worked correctly and command line indicates server is running:

running on http://0.0.0.0:500/ (Press CTRL+C to quit)

However when the browser tab opens you get a "This site can't be reached error".

Sidebar correctly shows my channels but main panel is blank

Hi there! I have slack-export-viewer running on a webserver and serving content. Running on Ubuntu 16 with Nginx running as a proxy.

It seems to be serving the channel pages correctly and responds 200:

WARNING: DEBUG MODE IS ENABLED!
/tmp/_slackviewer/45d904b9ddc5463d991e284949cd977d3b469e87 already exists
 * Debugger is active!
 * Debugger PIN: 234-449-011
127.0.0.1 - - [29/Nov/2017 18:43:54] "GET /channel/engineering HTTP/1.0" 200 -
127.0.0.1 - - [29/Nov/2017 18:43:54] "GET /static/viewer.css HTTP/1.0" 200 -
127.0.0.1 - - [29/Nov/2017 18:44:05] "GET /channel/engineering HTTP/1.0" 200 -
127.0.0.1 - - [29/Nov/2017 18:44:05] "GET /static/viewer.css HTTP/1.0" 200 -
127.0.0.1 - - [29/Nov/2017 18:44:08] "GET /channel/general HTTP/1.0" 200 -

I definitely have files in these channels:

$ ls -ltra engineering/*json
-rw-r--r-- 1 ubuntu ubuntu  45949 Nov 19 17:19 engineering/2017-05-22.json
-rw-r--r-- 1 ubuntu ubuntu   3868 Nov 19 17:19 engineering/2017-05-21.json
-rw-r--r-- 1 ubuntu ubuntu   1135 Nov 19 17:19 engineering/2017-05-20.json
-rw-r--r-- 1 ubuntu ubuntu  37899 Nov 19 17:19 engineering/2017-05-19.json
-rw-r--r-- 1 ubuntu ubuntu  55977 Nov 19 17:19 engineering/2017-05-18.json
...

But the HTML served has nothing in the messages area:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>#random</title>
    <link rel=stylesheet type=text/css
          href="/static/viewer.css">
</head>
<body>
<div id="fixed">
    <h3>Channels</h3>
    <ul id="channel-list">
        
            <li class="channel ">
                <a href="/channel/engineering">
                    #engineering
                </a>
            </li>
        
            <li class="channel ">
                <a href="/channel/general">
                    #general
                </a>
            </li>
        
            <li class="channel ">
                <a href="/channel/operations">
                    #operations
                </a>
            </li>
        
            <li class="channel active">
                <a href="/channel/random">
                    #random
                </a>
            </li>
        
    </ul>
</div>
<div class="messages" id="fluid">
    
</div>
</body>
</html>

Making it server ready

I want to make this deployable to a server so you can upload a zip and view the export.
@hfaran can you recommend a good way go about this?

Update:
I was able to easily make a view to upload and extract and separate that functionality from the CLI. Just working with gunicorn and docker now for a deployment.

Can't load new exports, but can load old ones. ValueError: Extra data:

ValueError: Extra data: line 33 column 2 - line 60 column 2 (char 1257 - 1952)

  File "/usr/local/bin/slack-export-viewer", line 11, in <module>
    load_entry_point('slack-export-viewer==0.4.2', 'console_scripts', 'slack-export-viewer')()
  File "/home/craig/.local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/craig/.local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/craig/.local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/craig/.local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/main.py", line 76, in main
    configure_app(app, archive, debug)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/main.py", line 40, in configure_app
    channels = compile_channels(path, user_data, channel_data)
  File "/usr/local/lib/python2.7/dist-packages/slackviewer/archive.py", line 49, in compile_channels
    day_messages = json.load(f)
  File "/usr/lib/python2.7/json/__init__.py", line 291, in load
    **kw)
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 367, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 33 column 2 - line 60 column 2 (char 1257 - 1952)```

JSON Dump error

Using python v2.7
python app.py -z MySlackExport.zip

gets this error when extracting the zip:

  File "app.py", line 6, in <module>
    main()
  File "/Library/Python/2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/tscritchfield/Documents/slack-export-viewer/slackviewer/main.py", line 86, in main
    configure_app(app, archive, debug)
  File "/Users/tscritchfield/Documents/slack-export-viewer/slackviewer/main.py", line 43, in configure_app
    path = extract_archive(archive)
  File "/Users/tscritchfield/Documents/slack-export-viewer/slackviewer/archive.py", line 203, in extract_archive
    json.dump(archive_info, f)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 190, in dump
    fp.write(chunk)
TypeError: must be unicode, not str

Is there another json dump argument or json to fix this?
I'll do some research to resolve this today.

A demo or an Example

It would be a great benefit if an example of the html output was in this repository. I can't seem to try it until #34 is fixed. Also, I would like contribute by improving the css, if the screenshot is accurate.

extracted archives not working

Hi @tscritch,
I can´t view the zip file after following instructions.
Here is the log:

MacBook-Air-de-Mikel:documents mikel$ slack-export-viewer -z slack162018.zip
slack162018.zip extracting to /var/folders/ph/gzh9clr1397fdk2m1013fhxc0000gn/T/_slackviewer/50ea6ff3ec9f9e745ead757609080e968c1c7706...
slack162018.zip extracted to /var/folders/ph/gzh9clr1397fdk2m1013fhxc0000gn/T/_slackviewer/50ea6ff3ec9f9e745ead757609080e968c1c7706
Traceback (most recent call last):
File "/usr/local/bin/slack-export-viewer", line 11, in
sys.exit(main())
File "/Library/Python/2.7/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 50, in main
configure_app(app, archive, debug)
File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 19, in configure_app
reader = Reader(path)
File "/Library/Python/2.7/site-packages/slackviewer/reader.py", line 16, in init
with io.open(os.path.join(self._PATH, "users.json"), encoding="utf8") as f:
IOError: [Errno 2] No such file or directory: '/var/folders/ph/gzh9clr1397fdk2m1013fhxc0000gn/T/_slackviewer/50ea6ff3ec9f9e745ead757609080e968c1c7706/users.json'

json.load ValueError(errmsg("Extra data", s, end, len(s)))

Hiya, I'm unable to get to the browser pop stage of the program, seeing the following:

admin$ slack-export-viewer -z slack_exp.zip
slack_exp.zip extracting to /var/folders/pw/9pswtvxj7214t6pjf5zdk3bc0000gn/T/_slackviewer/9e5361f4333a34ad9e8ca7a2fb08ec378a2bf40e...
slack_exp.zip extracted to /var/folders/pw/9pswtvxj7214t6pjf5zdk3bc0000gn/T/_slackviewer/9e5361f4333a34ad9e8ca7a2fb08ec378a2bf40e
Traceback (most recent call last):
File "/usr/local/bin/slack-export-viewer", line 11, in
sys.exit(main())
File "/Library/Python/2.7/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 50, in main
configure_app(app, archive, debug)
File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 22, in configure_app
top.channels = reader.compile_channels()
File "/Library/Python/2.7/site-packages/slackviewer/reader.py", line 31, in compile_channels
return self._create_messages(channel_names, channel_data)
File "/Library/Python/2.7/site-packages/slackviewer/reader.py", line 154, in _create_messages
day_messages = json.load(f)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 290, in load
**kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 369, in decode
raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 184 column 2 - line 219 column 2 (char 5446 - 6376)

Pagination support

I have a log data that like 200M.
One room has 20M data.
Opening slack-export-viewer will freeze my browser.

Do you have a plan to add per day/month page?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.