SMAT-CLI
Provides command line tools for getting data from the Social Media Analysis Toolkit (SMAT) as well as a library for interacting with SMAT from your own code.
The Social Media Analysis Toolkit is a resource that allows activists, journalists, researchers, and other social good organizations to collect information about hate, mis/disinformation, and extremism from a variety of online platforms. The folks at SMAT are providing an amazing service and deserve your support! Go to their Open Collective page to support them if you're able.
SMAT-CLI is a tool that makes getting that information from the API easy, either from your terminal or as part of your own application.
Installation
OS X & Linux:
pip install smat-cli
Though, I recommend using Pipx to install it as a a system tool.
pipx install smat-cli
Windows:
Coming soon!
Usage Examples
Let's say you want to collect 1000 posts from Telegram posted between Jan 6 to March 1, 2021. You can do that with the
content command like this.
smat content -s telegram -l 1000 --since 2021-01-06 --until 2021-03-01 trump
If you want some aggregated data, you can use the timeseries command to fetch a count of posts mentioning Trump from
Jan 6 to March 1, 2021 and aggregate those into daily buckets, you can use the following.
smat timeseries -s telegram -i day --since 2021-01-06 --until 2021-03-01 trump
You can also aggregate by any arbitrary key present in the data for the site. To get an idea of which keys are available,
you can examine the results of a content command. Once you know the key you want to aggregate on, you can use activity
to, for example, count the number of posts containing the term Trump in each Telegram channel from Jan 6 to March 1, 2022.
smat activity -s telegram -a channelusername --since 2021-01-06 --until 2021-03-01 trump
All above commands print output line-by-line to stdout in JSON, so you can pipe the results to a file in the normal way.
smat content -s telegram -l 1000 --since 2021-01-06 --until 2021-03-01 trump >> data.ndjson
You can also specify different formats for the output. For example, if you'd like the results in JSON instead of
JSONlines, you can pass --format json. This is currently the only way to format changepoint data when using
timeseries.
smat --format json content -s telegram -l 1000 --since 2021-01-06 --until 2021-03-01 trump > data.json
In addition, this package can be used in another application by importing Smat from smat_cli and using it to query
the API from inside your program.
from smat_cli import Smat
api = Smat()
data = api.content(term="trump", site="telegram", ...)
for d in data:
print(d["message"])
Development Setup
This project uses Poetry and the code is formatted with Black.
Tests can be run via Tox, which will run the tests in Python verions: 3.7, 3.8, 3.9, 3.10.
For this to work properly, all of these Python versions must be installed. A Dockerfile has been included in the test_runner
directory if necessary.
poetry install
tox
Release History
- 0.1.3
- Add new sites: TikTok, Rutube, Truth Social (@benzonip)
- Added support for Python 3.11
- 0.1.2
- Updates to package info and README
- Add formatters and JsonFormatter
- 0.1.1
- Updates to package info and README
- 0.1.0
- Initial release
Me
Daniel Hosterman – @dhosterman – daniel@danielhosterman.com
Distributed under the Unlicense license. See LICENSE for more information.
Contributing
- Fork it (https://github.com/yourname/yourproject/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Format your code with Black
- Ensure there are tests for your changes and that they pass
- Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
Contributors
- Peter Benzoni (@benzonip)
Metadata
Release files for smat-cli 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| smat_cli-0.1.3.tar.gz | 8.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smat_cli-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.3 kB
Release files / smat_cli-0.1.3.tar.gz
| Download URL | smat_cli-0.1.3.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7b3c846877af096e837c117040802f28bff85df2c83375bb5a7c1b7f2970937
|
|
BLAKE2b-256 checksum How to use checksums |
09323f7f411add3f0510014da14610fbf2080f3a1004f6d3252c5e38196df02b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Darwin/22.3.0
|
Release files / smat_cli-0.1.3-py3-none-any.whl
| Download URL | smat_cli-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
929fb01b440fdabceb88d9af76ef02b7ce1e45288a8e620304593a1835fc9f32
|
|
BLAKE2b-256 checksum How to use checksums |
c489a15e1e9c7b7e00f013b04c51ad68b33f2e30bc34460a7e7592a3cd66bd18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Darwin/22.3.0
|
Security for smat-cli 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.