mirror of
https://github.com/ihabunek/toot
synced 2025-02-04 13:17:33 +01:00
Enable getting public timelines without logging in
This commit is contained in:
parent
59efff5abc
commit
561506ee2d
13
toot/api.py
13
toot/api.py
@ -303,24 +303,17 @@ def reblogged_by(app, user, status_id) -> Response:
|
|||||||
def get_timeline_generator(
|
def get_timeline_generator(
|
||||||
app: Optional[App],
|
app: Optional[App],
|
||||||
user: Optional[User],
|
user: Optional[User],
|
||||||
base_url: Optional[str] = None,
|
|
||||||
account: Optional[str] = None,
|
account: Optional[str] = None,
|
||||||
list_id: Optional[str] = None,
|
list_id: Optional[str] = None,
|
||||||
tag: Optional[str] = None,
|
tag: Optional[str] = None,
|
||||||
local: bool = False,
|
local: bool = False,
|
||||||
public: bool = False,
|
public: bool = False,
|
||||||
limit=20, # TODO
|
limit: int = 20, # TODO
|
||||||
):
|
):
|
||||||
if public:
|
if public:
|
||||||
if base_url:
|
return public_timeline_generator(app, user, local=local, limit=limit)
|
||||||
return anon_public_timeline_generator(base_url, local=local, limit=limit)
|
|
||||||
else:
|
|
||||||
return public_timeline_generator(app, user, local=local, limit=limit)
|
|
||||||
elif tag:
|
elif tag:
|
||||||
if base_url:
|
return tag_timeline_generator(app, user, tag, local=local, limit=limit)
|
||||||
return anon_tag_timeline_generator(base_url, tag, limit=limit)
|
|
||||||
else:
|
|
||||||
return tag_timeline_generator(app, user, tag, local=local, limit=limit)
|
|
||||||
elif account:
|
elif account:
|
||||||
return account_timeline_generator(app, user, account, limit=limit)
|
return account_timeline_generator(app, user, account, limit=limit)
|
||||||
elif list_id:
|
elif list_id:
|
||||||
|
@ -2,7 +2,7 @@ import sys
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
from toot import api
|
from toot import api
|
||||||
from toot.cli import cli, pass_context, Context
|
from toot.cli import cli, get_context, pass_context, Context
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from toot.cli.validators import validate_instance
|
from toot.cli.validators import validate_instance
|
||||||
|
|
||||||
@ -37,9 +37,7 @@ from toot.output import print_notifications, print_timeline
|
|||||||
"--count", "-c", type=int, default=10,
|
"--count", "-c", type=int, default=10,
|
||||||
help="Number of posts per page (max 20)"
|
help="Number of posts per page (max 20)"
|
||||||
)
|
)
|
||||||
@pass_context
|
|
||||||
def timeline(
|
def timeline(
|
||||||
ctx: Context,
|
|
||||||
instance: Optional[str],
|
instance: Optional[str],
|
||||||
account: Optional[str],
|
account: Optional[str],
|
||||||
list: Optional[str],
|
list: Optional[str],
|
||||||
@ -63,20 +61,25 @@ def timeline(
|
|||||||
if instance and not (public or tag):
|
if instance and not (public or tag):
|
||||||
raise click.ClickException("The --instance option is only valid alongside --public or --tag.")
|
raise click.ClickException("The --instance option is only valid alongside --public or --tag.")
|
||||||
|
|
||||||
list_id = _get_list_id(ctx, list)
|
if public and instance:
|
||||||
|
generator = api.anon_public_timeline_generator(instance, local, count)
|
||||||
|
elif tag and instance:
|
||||||
|
generator = api.anon_tag_timeline_generator(instance, tag, local, count)
|
||||||
|
else:
|
||||||
|
ctx = get_context()
|
||||||
|
list_id = _get_list_id(ctx, list)
|
||||||
|
|
||||||
"""Show recent statuses in a timeline"""
|
"""Show recent statuses in a timeline"""
|
||||||
generator = api.get_timeline_generator(
|
generator = api.get_timeline_generator(
|
||||||
ctx.app,
|
ctx.app,
|
||||||
ctx.user,
|
ctx.user,
|
||||||
base_url=instance,
|
account=account,
|
||||||
account=account,
|
list_id=list_id,
|
||||||
list_id=list_id,
|
tag=tag,
|
||||||
tag=tag,
|
public=public,
|
||||||
public=public,
|
local=local,
|
||||||
local=local,
|
limit=count,
|
||||||
limit=count,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
_show_timeline(generator, reverse, once)
|
_show_timeline(generator, reverse, once)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user