Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazyloading #1186

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
3572dd7
Replace tokens with guest accounts, swap endpoints
zedeus Aug 18, 2023
bbd68e6
Filter out account limits that already reset
zedeus Aug 18, 2023
3d8858f
Track rate limits, reset after 24 hours
zedeus Aug 20, 2023
e8b5cbe
Add missing limitedAt assignment
zedeus Aug 20, 2023
51714b5
Add guest accounts variable to GitHub action
zedeus Aug 21, 2023
c3d9441
Unify some guest account logs
zedeus Aug 21, 2023
12504bc
Fix compilation error
zedeus Aug 21, 2023
30bdf3a
Reduce max concurrent pending requests per account
zedeus Aug 21, 2023
5c08e6a
Fix compilation on older versions of Nim
zedeus Aug 22, 2023
6e87449
Tweak /.tokens, add amount of limited accounts
zedeus Aug 22, 2023
8df5256
Switch back to old user search endpoint
zedeus Aug 22, 2023
4580836
Fix tweetDetail stats
zedeus Aug 22, 2023
a3e11e3
Switch to using typeahead for user search
zedeus Aug 23, 2023
88b005c
Revert "Switch to using typeahead for user search"
zedeus Aug 23, 2023
ae9fa02
Switch to TweetDetail for tweets
zedeus Aug 25, 2023
03794a8
Cleanup
zedeus Aug 25, 2023
7630f57
Fix cards not being displayed
zedeus Aug 26, 2023
4ccf350
Improve .tokens output
zedeus Aug 29, 2023
986b91a
Handle ProtocolError and BadClientError equally
zedeus Aug 29, 2023
898b19b
Improve rate limit handling, minor refactor
zedeus Aug 30, 2023
37b58a5
Fix accounts logging
zedeus Aug 30, 2023
282ce8b
Add 429 logging
zedeus Aug 30, 2023
82beb5d
Add empty oauth token logging
zedeus Aug 30, 2023
84dcf49
Fix negative pending requests bug
zedeus Aug 31, 2023
b8fe212
Add media proxying error logging
zedeus Sep 1, 2023
4250245
Shorten media proxy error log
zedeus Sep 2, 2023
fcd74e8
Retry rate limited requests with different account
zedeus Sep 2, 2023
14f9a09
Fix crash on missing quote tweet data crash
zedeus Sep 14, 2023
7abcb48
Increase photo rail cache ttl
zedeus Sep 18, 2023
7d14789
Improve guest accounts loading, add JSONL support
zedeus Sep 18, 2023
537af7f
Improve Liberapay css for Firefox compatibility
zedeus Sep 19, 2023
735b30c
fix(nitter): add graphql user search (#1047)
DrSocket Oct 30, 2023
32e3469
Fix multi-user timelines
zedeus Oct 31, 2023
edad09f
Update nimcrypto and jsony
zedeus Oct 31, 2023
0892758
Bump minimum Nim version
zedeus Oct 31, 2023
4120558
Replace /.tokens with /.health and /.accounts
zedeus Oct 31, 2023
b8103cf
Fix compilation on Nim 1.6.x
zedeus Oct 31, 2023
60a8256
Run tests on multiple Nim versions
zedeus Oct 31, 2023
bd0be72
Merge branch 'master' into guest_accounts
zedeus Oct 31, 2023
b930a3d
Fix guest accounts CI setup
zedeus Oct 31, 2023
33bad37
Fix guest accounts CI setup attempt 2
zedeus Nov 1, 2023
006b91c
Prevent annoying warnings on devel
zedeus Nov 1, 2023
b0b3351
Fix missing CI file argument
zedeus Nov 1, 2023
58e73a1
Fix guest accounts CI setup attempt 3
zedeus Nov 1, 2023
1d20bd0
Remove redundant "active" field from /.health
zedeus Nov 1, 2023
7b3fcdc
Fix guest accounts CI setup attempt 4
zedeus Nov 1, 2023
623424f
Fix outdated test
zedeus Nov 1, 2023
e1838e0
Move CI workflow to buildjet
zedeus Nov 1, 2023
209f453
Purge expired accounts after parsing
zedeus Nov 1, 2023
d175832
Don't requests made before reset
zedeus Nov 1, 2023
e0d9dd0
Fix #670
zedeus Nov 4, 2023
5e18864
Bump Nim in the ARM64 Dockerfile, add nitter user
zedeus Nov 8, 2023
eaedd2a
Fix ARM64 Dockerfile versions
zedeus Nov 8, 2023
c2819da
Fix #1106
zedeus Nov 15, 2023
06ab1ea
Enable disabled tests
zedeus Nov 15, 2023
4dac9f0
Add simple job_details card support
zedeus Nov 25, 2023
d6be08d
Fix jobDetails error on old Nim versions
zedeus Nov 25, 2023
f8254c2
Add support for business and gov verification
zedeus Nov 25, 2023
a9740fe
Fix compilation with old Nim again
zedeus Nov 25, 2023
583c858
Fix search queries in user search RSS feeds (#1126)
the-blank-x Dec 3, 2023
52db03b
Fix broken video playback by forcing fmp4
zedeus Jan 12, 2024
cdff5e9
Fix for #1147, Proxy for audio URL and upgrade hls.js (#1178)
jackyzy823 Feb 21, 2024
c6edec0
Update auth.nim (#1164)
somini Feb 26, 2024
73732a9
Merge pull request #1 from alnmy/guest_accounts
alnmy Feb 26, 2024
e7f206a
Actions build-docker: Don't build arm64 images
alnmy Feb 26, 2024
4a23d4b
Publish Docker images to ghcr.io
alnmy Feb 26, 2024
6c995b8
Delete .github/FUNDING.yml
alnmy Feb 26, 2024
2d7ca0e
build-docker.yml: ubuntu-22.04 runner
alnmy Feb 26, 2024
6fac07f
Delete .github/workflows/run-tests.yml
alnmy Feb 26, 2024
6efef58
Don't run tests for GitHub Actions
alnmy Feb 26, 2024
8aeac2d
Merge pull request #2 from alnmy/use-gh-runners
alnmy Feb 26, 2024
f3f5f0e
Require need for tests in Actions
alnmy Feb 26, 2024
abf63ab
Use secrets.GITHUB_TOKEN
alnmy Feb 26, 2024
1322d13
Use ghcr.io for build-push-action
alnmy Feb 26, 2024
87b836e
lazyload images: pr #1157 zedeus/nitter
alnmy Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/FUNDING.yml

This file was deleted.

37 changes: 5 additions & 32 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ on:
- master

jobs:
tests:
uses: ./.github/workflows/run-tests.yml
build-docker-amd64:
needs: [tests]
runs-on: buildjet-2vcpu-ubuntu-2204
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -25,38 +22,14 @@ jobs:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push AMD64 Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: zedeus/nitter:latest,zedeus/nitter:${{ github.sha }}
build-docker-arm64:
needs: [tests]
runs-on: buildjet-2vcpu-ubuntu-2204-arm
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push ARM64 Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.arm64
platforms: linux/arm64
push: true
tags: zedeus/nitter:latest-arm64,zedeus/nitter:${{ github.sha }}-arm64
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.sha }}
45 changes: 0 additions & 45 deletions .github/workflows/run-tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ nitter
/public/css/style.css
/public/md/*.html
nitter.conf
guest_accounts.json*
dump.rdb
6 changes: 4 additions & 2 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.18 as nim
LABEL maintainer="[email protected]"

RUN apk --no-cache add gcc git libc-dev libsass-dev "nim=1.6.14-r0" nimble pcre
RUN apk --no-cache add libsass-dev pcre gcc git libc-dev "nim=1.6.14-r0" "nimble=0.13.1-r2"

WORKDIR /src/nitter

Expand All @@ -15,9 +15,11 @@ RUN nimble build -d:danger -d:lto -d:strip \

FROM alpine:3.18
WORKDIR /src/
RUN apk --no-cache add ca-certificates pcre openssl1.1-compat
RUN apk --no-cache add pcre ca-certificates openssl1.1-compat
COPY --from=nim /src/nitter/nitter ./
COPY --from=nim /src/nitter/nitter.example.conf ./nitter.conf
COPY --from=nim /src/nitter/public ./public
EXPOSE 8080
RUN adduser -h /src/ -D -s /bin/sh nitter
USER nitter
CMD ./nitter
7 changes: 1 addition & 6 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@

# disable annoying warnings
warning("GcUnsafe2", off)
warning("HoleEnumConv", off)
hint("XDeclaredButNotUsed", off)
hint("XCannotRaiseY", off)
hint("User", off)

const
nimVersion = (major: NimMajor, minor: NimMinor, patch: NimPatch)

when nimVersion >= (1, 6, 0):
warning("HoleEnumConv", off)
2 changes: 1 addition & 1 deletion nitter.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ redisMaxConnections = 30
hmacKey = "secretkey" # random key for cryptographic signing of video urls
base64Media = false # use base64 encoding for proxied media urls
enableRSS = true # set this to false to disable RSS feeds
enableDebug = false # enable request logs and debug endpoints (/.tokens)
enableDebug = false # enable request logs and debug endpoints (/.accounts)
proxy = "" # http/https url, SOCKS proxies are not supported
proxyAuth = ""
tokenCount = 10
Expand Down
6 changes: 3 additions & 3 deletions nitter.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ requires "nim >= 1.6.10"
requires "jester#baca3f"
requires "karax#5cf360c"
requires "sass#7dfdd03"
requires "nimcrypto#4014ef9"
requires "nimcrypto#a079df9"
requires "markdown#158efe3"
requires "packedjson#9e6fbb6"
requires "supersnappy#6c94198"
requires "redpool#8b7c1db"
requires "https://github.com/zedeus/redis#d0a0e6f"
requires "zippy#ca5989a"
requires "flatty#e668085"
requires "jsony#ea811be"

requires "jsony#1de1f08"
requires "oauth#b8c163b"

# Tasks

Expand Down
5 changes: 0 additions & 5 deletions public/js/hls.light.min.js

This file was deleted.

5 changes: 5 additions & 0 deletions public/js/hls.min.js

Large diffs are not rendered by default.

68 changes: 18 additions & 50 deletions src/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@ proc getGraphUserTweets*(id: string; kind: TimelineKind; after=""): Future[Profi
js = await fetch(url ? params, apiId)
result = parseGraphTimeline(js, "user", after)

# proc getTimeline*(id: string; after=""; replies=false): Future[Profile] {.async.} =
# if id.len == 0: return
# let
# ps = genParams({"userId": id, "include_tweet_replies": $replies}, after)
# url = oldUserTweets / (id & ".json") ? ps
# result = parseTimeline(await fetch(url, Api.timeline), after)

proc getUserTimeline*(id: string; after=""): Future[Profile] {.async.} =
var ps = genParams({"id": id})
if after.len > 0:
ps.add ("down_cursor", after)

let
url = legacyUserTweets ? ps
js = await fetch(url, Api.userTimeline)
result = parseUserTimeline(js, after)

proc getGraphListTweets*(id: string; after=""): Future[Timeline] {.async.} =
if id.len == 0: return
let
Expand Down Expand Up @@ -112,10 +95,10 @@ proc getTweet*(id: string; after=""): Future[Conversation] {.async.} =
if after.len > 0:
result.replies = await getReplies(id, after)

proc getGraphSearch*(query: Query; after=""): Future[Profile] {.async.} =
proc getGraphTweetSearch*(query: Query; after=""): Future[Timeline] {.async.} =
let q = genQueryParam(query)
if q.len == 0 or q == emptyQuery:
return Profile(tweets: Timeline(query: query, beginning: true))
return Timeline(query: query, beginning: true)

var
variables = %*{
Expand All @@ -129,44 +112,29 @@ proc getGraphSearch*(query: Query; after=""): Future[Profile] {.async.} =
if after.len > 0:
variables["cursor"] = % after
let url = graphSearchTimeline ? {"variables": $variables, "features": gqlFeatures}
result = Profile(tweets: parseGraphSearch(await fetch(url, Api.search), after))
result.tweets.query = query

proc getTweetSearch*(query: Query; after=""): Future[Timeline] {.async.} =
var q = genQueryParam(query)

if q.len == 0 or q == emptyQuery:
return Timeline(query: query, beginning: true)

if after.len > 0:
q &= " max_id:" & after

let url = tweetSearch ? genParams({
"q": q ,
"modules": "status",
"result_type": "recent",
})

result = parseTweetSearch(await fetch(url, Api.search), after)
result = parseGraphSearch[Tweets](await fetch(url, Api.search), after)
result.query = query

proc getUserSearch*(query: Query; page="1"): Future[Result[User]] {.async.} =
proc getGraphUserSearch*(query: Query; after=""): Future[Result[User]] {.async.} =
if query.text.len == 0:
return Result[User](query: query, beginning: true)

var url = userSearch ? {
"q": query.text,
"skip_status": "1",
"count": "20",
"page": page
}
var
variables = %*{
"rawQuery": query.text,
"count": 20,
"product": "People",
"withDownvotePerspective": false,
"withReactionsMetadata": false,
"withReactionsPerspective": false
}
if after.len > 0:
variables["cursor"] = % after
result.beginning = false

result = parseUsers(await fetchRaw(url, Api.userSearch))
let url = graphSearchTimeline ? {"variables": $variables, "features": gqlFeatures}
result = parseGraphSearch[User](await fetch(url, Api.search), after)
result.query = query
if page.len == 0:
result.bottom = "2"
elif page.allCharsInSet(Digits):
result.bottom = $(parseInt(page) + 1)

proc getPhotoRail*(name: string): Future[PhotoRail] {.async.} =
if name.len == 0: return
Expand Down
Loading