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

Replace tokens with guest accounts, swap endpoints #985

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 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
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
23 changes: 17 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,34 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: buildjet-2vcpu-ubuntu-2204
strategy:
matrix:
nim:
- "1.6.10"
- "1.6.x"
- "2.0.x"
- "devel"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache nimble
id: cache-nimble
uses: actions/cache@v3
uses: buildjet/cache@v3
with:
path: ~/.nimble
key: nimble-${{ hashFiles('*.nimble') }}
restore-keys: "nimble-"
key: ${{ matrix.nim }}-nimble-${{ hashFiles('*.nimble') }}
restore-keys: |
${{ matrix.nim }}-nimble-
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: "1.x"
nim-version: ${{ matrix.nim }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: nimble build -d:release -Y
- run: pip install seleniumbase
- run: seleniumbase install chromedriver
Expand All @@ -37,9 +46,11 @@ jobs:
run: |
sudo apt install libsass-dev -y
cp nitter.example.conf nitter.conf
sed -i 's/enableDebug = false/enableDebug = true/g' nitter.conf
nimble md
nimble scss
echo '${{ secrets.GUEST_ACCOUNTS }}' > ./guest_accounts.jsonl
- name: Run tests
run: |
./nitter &
pytest -n4 tests
pytest -n8 tests
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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bumps your requires nim to requires "nim >= 1.6", nitter doesn't build anymore with nim 1.4.8 because of this.

Copy link
Owner Author

@zedeus zedeus Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks. 1.6.0 was released two full years ago, so I think it's time to bump that anyway. Debian is on 1.6.14 and Ubuntu 23.04 is 1.6.10, so I'll set that as the minimum.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created a PR for that: #1053

Copy link

@Lomanic Lomanic Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally your CI should build nitter with this minimum version instead of some loose 1.x to catch this in the future.

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
Loading