1
0
Fork 0
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:
Lomanic 2021-06-27 04:06:13 +02:00 committed by Cadence Ember
parent 1ea86101fd
commit 3f57d50893
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
3 changed files with 62 additions and 1 deletions

View file

@ -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: