delab-socialmedia

A python library to facilitate downloading conversation trees from social media platforms like Twitter, Reddit or Mastodon.

https://github.com/juliandehne/delab-socialmedia

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

A python library to facilitate downloading conversation trees from social media platforms like Twitter, Reddit or Mastodon.

Basic Info
  • Host: GitHub
  • Owner: juliandehne
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 86.9 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Created over 2 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License Citation

README.md

delab-socialmedia

A python library to facilitate downloading conversation trees from social media platforms like Twitter, Reddit or Mastodon.

Overview

This library provides a unified interface for downloading conversations from Twitter, Reddit, and Mastodon. It simplifies the process of querying and retrieving conversations based on specific criteria, such as language, query string, and the recency of conversations. The library is designed to work with connectors specific to each platform, such as twarc for Twitter, praw for Reddit, and the Mastodon API for Mastodon.

Features

  • Download conversations from Twitter, Reddit, and Mastodon using a unified interface.
  • Filter conversations by language, query string, and recency.
  • Download the conversations in a unified format DelabTree that allows CSS analysis for the conversation trees, but also exports as pandas dataframe or networkx graph
  • Validate and filter the downloaded conversations based on custom criteria.
  • Download a daily sample of political discussions for CSS research
  • NOTE: Twitter functions have not been tested since its demise

Installation

bash pip install delab-socialmedia

Getting Started

Before you begin, make sure you have the necessary credentials: - For Reddit: reddit_secret, reddit_script_id, reddit_user, reddit_password, user_agent - For Mastodon: client_id, client_secret, access_token

Reddit Connector (get_praw function)

This function creates a connector for Reddit using the praw library.

Direct Variable Setting

```python from connectionutil import getpraw

reddit = getpraw( redditsecret='YOURREDDITSECRET', redditscriptid='YOURREDDITSCRIPTID', reddituser='YOURREDDITUSERNAME', redditpassword='YOURREDDITPASSWORD', useragent='YOURUSERAGENT' ) ```

Use YAML

yaml reddit_secret: YOUR_REDDIT_SECRET reddit_script_id: YOUR_REDDIT_SCRIPT_ID reddit_user: YOUR_REDDIT_USERNAME reddit_password: YOUR_REDDIT_PASSWORD user_agent: YOUR_USER_AGENT

and

python from connection_util import get_praw reddit = get_praw( use_yaml=True, yaml_path='path/to/your/social_media_credentials.yml' )

Mastodon Connector (create_mastodon function)

Direct Variable Setting

```python from connectionutil import createmastodon

mastodon = createmastodon( clientid='YOURCLIENTID', clientsecret='YOURCLIENTSECRET', accesstoken='YOURACCESSTOKEN', apibaseurl='https://mastodon.social/' ) ```

Use YAML

yaml client_id: YOUR_CLIENT_ID client_secret: YOUR_CLIENT_SECRET access_token: YOUR_ACCESS_TOKEN api_base_url: https://mastodon.social/

and

```python from connectionutil import createmastodon

mastodon = createmastodon( useyaml=True, yamlpath='path/to/your/socialmedia_credentials.yml' ) ```

Twitter Connector

Analogously, for Twitter, although the Twitter access has not been tested.

```python from twarc import Twarc2

class DelabTwarc(Twarc2): def init(self, accesstoken=None, accesstokensecret=None, bearertoken=None, consumerkey=None, consumersecret=None, useyaml=False, yamlpath=None): """ create the Twitter connector :param accesstoken: :param accesstokensecret: :param bearertoken: :param consumerkey: :param consumersecret: :param useyaml: :param yamlpath: """ ...

```

Download daily sample

```python from models.language import LANGUAGE from models.platform import PLATFORM from connectionutil import createmastodon from socialmedia import downloaddailysample_conversations

connector = createmastodon() conversations = downloaddailysampleconversations(platform=PLATFORM.MASTODON, language=LANGUAGE.ENGLISH, min_results=5, connector=connector) ```

Download Conversations

The library provides functions to download conversations based on various parameters. Here's an example of downloading conversations from Reddit:

```python from socialmedia import downloadconversations, PLATFORM, LANGUAGE from connectionutil import get_praw

connector = getpraw() conversations = downloadconversations(querystring="Politics", platform=PLATFORM.REDDIT, language=LANGUAGE.ENGLISH, recent=True, maxconversations=30, connector=connector) ```

Get Conversations by User

To get all conversations a given user has participated in on Reddit or Mastodon:

```python from socialmedia import getconversationsby_user, PLATFORM

from connectionutil import getpraw

connector = getpraw() userconversations = getconversationsbyuser(username="u/exampleuser", platform=PLATFORM.REDDIT, connector=connector) ```

Contribution

Contributions to improve the library are welcome. Please submit pull requests or open issues to suggest changes or report bugs.

License

MIT

Owner

  • Login: juliandehne
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software in your research, please cite it using the following metadata."
title: "delab-socialmedia, a python library to download conversation trees from social media"
version: 0.0.1
date-released: 2023-09-18

authors:
  - given-names: Julian
    family-names: Dehne
    affiliation: "University of Göttingen"
    orcid: "https://orcid.org/0000-0001-9265-9619"

repository-code: "https://github.com/juliandehne/delab-socialmedia"
license: MIT

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • pvonderhaar (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 13 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
pypi.org: delab-socialmedia

a library to download reply trees in forums and social media

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 13 Last month
Rankings
Dependent packages count: 9.6%
Average: 36.5%
Dependent repos count: 63.3%
Maintainers (1)
Last synced: 10 months ago