mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-05-04 16:41:37 +00:00
Retrieve the first 20 comments of a video on /api/v1/comments/:videoid
Got some inspiration from https://github.com/nlitsme/youtube_tool (for the x-youtube-client-X headers). This is not a complete reimplementation of Invidious API as continuation is not implemented (to retrieve more than the first 20 comments and comments replies), likes and replies count are also missing.
This commit is contained in:
parent
1ea86101fd
commit
3f57d50893
3 changed files with 62 additions and 1 deletions
9
index.py
9
index.py
|
|
@ -9,6 +9,7 @@ from extractors.manifest import extract_manifest
|
|||
from extractors.search import extract_search
|
||||
from extractors.suggestions import extract_search_suggestions
|
||||
from extractors.captions import extract_captions
|
||||
from extractors.comments import extract_comments
|
||||
import configuration
|
||||
|
||||
@cherrypy.tools.register("before_finalize", priority=60)
|
||||
|
|
@ -26,7 +27,8 @@ class NewLeaf(object):
|
|||
["channels", 1, 2],
|
||||
["videos", 1, 1],
|
||||
["search", 0, 1],
|
||||
["captions", 1, 1]
|
||||
["captions", 1, 1],
|
||||
["comments", 1, 1]
|
||||
]
|
||||
for e in endpoints:
|
||||
if vpath[2] == e[0] and len(vpath) >= e[1]+3 and len(vpath) <= e[2]+3:
|
||||
|
|
@ -114,6 +116,11 @@ class NewLeaf(object):
|
|||
"identifier": "NO_MATCHING_CAPTIONS"
|
||||
}), "utf8")
|
||||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
def comments(self, id, **kwargs):
|
||||
return extract_comments(id)
|
||||
|
||||
@cherrypy.expose
|
||||
def vi(self, id, file):
|
||||
with requests.get("https://i.ytimg.com/vi/{}/{}".format(id, file)) as r:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue