GithubHelp home page GithubHelp logo

jakewharton / dodo Goto Github PK

View Code? Open in Web Editor NEW
181.0 5.0 8.0 468 KB

Synchronize your Twitter timeline to a local database for archival and search

License: Apache License 2.0

Dockerfile 5.99% Shell 14.95% Kotlin 77.86% JavaScript 1.20%

dodo's Introduction

Dodo

Synchronize your Twitter timeline to a local database for archival and search.

Screenshot of web interface

Available as a binary and Docker container.

Usage

Dodo consumes data from Twitter and requires you register your own Twitter application for keys: https://developer.twitter.com/en/apply-for-access

You will need an OAuth access token and access secret as well as an API key and secret.

From there, you can run Dodo in one of two ways:

Command-line

Install on Mac OS with:

$ brew install JakeWharton/repo/dodo

For other platforms, download ZIP from latest release and run bin/dodo or bin/dodo.bat.

Dodo can run in two modes:

  • One-off syncs via sync subcommand, or
  • Long-running web-server with manual syncs
$ dodo --help
Usage: dodo [OPTIONS] COMMAND [ARGS]...

Options:
  -h, --help  Show this message and exit

Commands:
  sync  Perform a one-time sync of the latest tweets
  run   Start an HTTP server for displaying tweets and performing syncs

The sync subcommand will perform a one-off sync to the specified Sqlite database file. You can run it on a cron and use sqlite3 or any Sqlite-capable tool to consume the data.

$ dodo sync --help
Usage: dodo sync [OPTIONS]

  Perform a one-time sync of the latest tweets

Options:
  --db FILE            Sqlite database file
  --access-token KEY   OAuth access token
  --access-secret KEY  OAuth access token secret
  --api-key KEY        OAuth consumer API key
  --api-secret KEY     OAuth consumer API secret
  -h, --help           Show this message and exit

The run subcommand will start a webserver with a search and manual sync interface. You can also POST the /sync endpoint to trigger a sync, such as on a cron.

$ dodo run --help
Usage: dodo run [OPTIONS]

  Start an HTTP server for displaying tweets and performing syncs

Options:
  --db FILE            Sqlite database file
  --access-token KEY   OAuth access token
  --access-secret KEY  OAuth access token secret
  --api-key KEY        OAuth consumer API key
  --api-secret KEY     OAuth consumer API secret
  --port PORT          Port for the HTTP server (default 8098)
  -h, --help           Show this message and exit

Docker

The container starts the webserver on port 8098 and automatically triggers sync using cron.

Docker Image Version Docker Image Size

$ docker run -it --rm \
    -v /path/to/data:/data \
    -e "CRON=*/3 * * * *" \
    -e "ACCESS_TOKEN=..." \
    -e "ACCESS_SECRET=..." \
    -e "API_KEY=..." \
    -e "API_SECRET=..." \
    jakewharton/dodo:trunk

To be notified when sync is failing visit https://healthchecks.io, create a check, and specify the ID to the container using the HEALTHCHECK_ID environment variable.

Docker Compose

version: '2'
services:
  dodo:
    image: jakewharton/dodo:trunk
    restart: unless-stopped
    volumes:
      - /path/to/data:/data
    environment:
      - "CRON=*/3 * * * *"
      - "ACCESS_TOKEN=..."
      - "ACCESS_SECRET=..."
      - "API_KEY=..."
      - "API_SECRET=..."
      #Optional:
      - "HEALTHCHECK_ID=..."
      - "PUID=..."
      - "PGID=..."

Development

To run the latest code build with ./gradlew installDist. This will put the application into build/install/dodo/. From there you can use the command-line instructions instructions to run.

The Docker containers can be built with docker build ., which also runs the full set of checks as CI would.

License

Copyright 2020 Jake Wharton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

dodo's People

Contributors

jakewharton avatar kevincianfarini avatar renovate[bot] avatar rock3r 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

dodo's Issues

Leverage SQLite full text search

I noticed that the search functionality uses like across the columns of interest. It might be worth it to investigate if SQLite Full Text Search could be used to provide a more robust search experience (like tweets being ranked by relevance to the query).

I'd be more than happy to create a PR for this if you're open to it.

Search operators

  • id:123
  • username:foo - search username to get IDs associated with, then search by all IDs.
  • before:YYYY-MM-DD / after:YYYY-MM-DD

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

dockerfile
Dockerfile
  • adoptopenjdk 8-jdk-hotspot
  • mvdan/shfmt v3-alpine
  • oznu/s6-alpine 3.11
github-actions
.github/workflows/build.yaml
  • actions/checkout v3
  • gradle/wrapper-validation-action v1
.github/workflows/build_and_publish.yaml
  • actions/checkout v3
  • gradle/wrapper-validation-action v1
  • actions/setup-java v3
  • crazy-max/ghaction-docker-meta v1
  • docker/login-action v2
  • docker/build-push-action v4
  • ffurrer2/extract-release-notes v1
  • softprops/action-gh-release v1
gradle
settings.gradle
build.gradle
  • org.jetbrains.kotlin:kotlin-gradle-plugin 1.8.20
  • com.squareup.sqldelight:gradle-plugin 1.5.4
  • org.jetbrains.kotlinx:kotlinx-coroutines-core 1.6.4
  • com.github.ajalt.clikt:clikt 3.5.2
  • com.squareup.sqldelight:sqlite-driver 1.5.4
  • org.xerial:sqlite-jdbc 3.41.2.1
  • org.twitter4j:twitter4j-core 4.1.2
  • ch.qos.logback:logback-classic 1.4.6
  • io.ktor:ktor-server-core 1.6.8
  • io.ktor:ktor-server-netty 1.6.8
  • io.ktor:ktor-html-builder 1.6.8
  • junit:junit 4.13.2
  • com.google.truth:truth 1.1.3
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.1

  • Check this box to trigger a request for Renovate to run again on this repository

Crash on startup on macOS Ventura on Apple Silicon

Running the sync command on an Apple Silicon Mac, running macOS Ventura, results in this crash:

Exception in thread "main" java.sql.SQLException: Error opening connection
	at org.sqlite.core.CoreConnection.open(CoreConnection.java:215)
	at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
	at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25)
	at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
	at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
	at org.sqlite.JDBC.createConnection(JDBC.java:114)
	at org.sqlite.JDBC.connect(JDBC.java:88)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:683)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:191)
	at com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver.<init>(JdbcSqliteDriver.kt:25)
	at com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver.<init>(JdbcSqliteDriver.kt:14)
	at com.jakewharton.dodo.DodoCommand.run(main.kt:118)
	at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:171)
	at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:180)
	at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:16)
	at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:395)
	at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:392)
	at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:410)
	at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:435)
	at com.jakewharton.dodo.Main.main(main.kt:28)
Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64
	at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:333)
	at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:64)
	at org.sqlite.core.NativeDB.load(NativeDB.java:56)
	at org.sqlite.core.CoreConnection.open(CoreConnection.java:211)
	... 19 more

Searching with "@" crashes sqlite FTS

dodo                      | org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (fts5: syntax error near "@")
dodo                      |     at org.sqlite.core.DB.newSQLException(DB.java:1012)
dodo                      |     at org.sqlite.core.DB.newSQLException(DB.java:1024)
dodo                      |     at org.sqlite.core.DB.execute(DB.java:866)
dodo                      |     at org.sqlite.jdbc3.JDBC3PreparedStatement.executeQuery(JDBC3PreparedStatement.java:77)
dodo                      |     at com.squareup.sqldelight.sqlite.driver.SqliteJdbcPreparedStatement.executeQuery$sqldelight_jdbc_driver(JdbcDriver.kt:144)
dodo                      |     at com.squareup.sqldelight.sqlite.driver.JdbcDriver.executeQuery(JdbcDriver.kt:71)
dodo                      |     at com.jakewharton.dodo.db.dodo.TweetIndexQueriesImpl$SearchQuery.execute(DatabaseImpl.kt:424)
dodo                      |     at com.squareup.sqldelight.Query.executeAsList(Query.kt:134)
dodo                      |     at com.jakewharton.dodo.Dodo$search$2.invokeSuspend(app.kt:71)
dodo                      |     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
dodo                      |     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
dodo                      | 2021-03-02 22:47:03.886 [nioEventLoopGroup-4-1] ERROR ktor.application - Unhandled: GET - /
dodo                      | org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (fts5: syntax error near "@")
dodo                      |     at org.sqlite.core.DB.newSQLException(DB.java:1012)
dodo                      |     at org.sqlite.core.DB.newSQLException(DB.java:1024)
dodo                      |     at org.sqlite.core.DB.execute(DB.java:866)
dodo                      |     at org.sqlite.jdbc3.JDBC3PreparedStatement.executeQuery(JDBC3PreparedStatement.java:77)
dodo                      |     at com.squareup.sqldelight.sqlite.driver.SqliteJdbcPreparedStatement.executeQuery$sqldelight_jdbc_driver(JdbcDriver.kt:144)
dodo                      |     at com.squareup.sqldelight.sqlite.driver.JdbcDriver.executeQuery(JdbcDriver.kt:71)
dodo                      |     at com.jakewharton.dodo.db.dodo.TweetIndexQueriesImpl$SearchQuery.execute(DatabaseImpl.kt:424)
dodo                      |     at com.squareup.sqldelight.Query.executeAsList(Query.kt:134)
dodo                      |     at com.jakewharton.dodo.Dodo$search$2.invokeSuspend(app.kt:71)
dodo                      |     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
dodo                      |     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
dodo                      |     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

search for anything with "@" in it.

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.