mirror of
https://github.com/ihabunek/toot
synced 2025-02-04 05:08:01 +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(
|
||||
app: Optional[App],
|
||||
user: Optional[User],
|
||||
base_url: Optional[str] = None,
|
||||
account: Optional[str] = None,
|
||||
list_id: Optional[str] = None,
|
||||
tag: Optional[str] = None,
|
||||
local: bool = False,
|
||||
public: bool = False,
|
||||
limit=20, # TODO
|
||||
limit: int = 20, # TODO
|
||||
):
|
||||
if public:
|
||||
if base_url:
|
||||
return anon_public_timeline_generator(base_url, local=local, limit=limit)
|
||||
else:
|
||||
return public_timeline_generator(app, user, local=local, limit=limit)
|
||||
return public_timeline_generator(app, user, local=local, limit=limit)
|
||||
elif tag:
|
||||
if base_url:
|
||||
return anon_tag_timeline_generator(base_url, tag, limit=limit)
|
||||
else:
|
||||
return tag_timeline_generator(app, user, tag, local=local, limit=limit)
|
||||
return tag_timeline_generator(app, user, tag, local=local, limit=limit)
|
||||
elif account:
|
||||
return account_timeline_generator(app, user, account, limit=limit)
|
||||
elif list_id:
|
||||
|
@ -2,7 +2,7 @@ import sys
|
||||
import click
|
||||
|
||||
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 toot.cli.validators import validate_instance
|
||||
|
||||
@ -37,9 +37,7 @@ from toot.output import print_notifications, print_timeline
|
||||
"--count", "-c", type=int, default=10,
|
||||
help="Number of posts per page (max 20)"
|
||||
)
|
||||
@pass_context
|
||||
def timeline(
|
||||
ctx: Context,
|
||||
instance: Optional[str],
|
||||
account: Optional[str],
|
||||
list: Optional[str],
|
||||
@ -63,20 +61,25 @@ def timeline(
|
||||
if instance and not (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"""
|
||||
generator = api.get_timeline_generator(
|
||||
ctx.app,
|
||||
ctx.user,
|
||||
base_url=instance,
|
||||
account=account,
|
||||
list_id=list_id,
|
||||
tag=tag,
|
||||
public=public,
|
||||
local=local,
|
||||
limit=count,
|
||||
)
|
||||
"""Show recent statuses in a timeline"""
|
||||
generator = api.get_timeline_generator(
|
||||
ctx.app,
|
||||
ctx.user,
|
||||
account=account,
|
||||
list_id=list_id,
|
||||
tag=tag,
|
||||
public=public,
|
||||
local=local,
|
||||
limit=count,
|
||||
)
|
||||
|
||||
_show_timeline(generator, reverse, once)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user