res.py 1.0 KB

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2023 MikuInvidious Team
  2. #
  3. # MikuInvidious is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License as
  5. # published by the Free Software Foundation; either version 3 of
  6. # the License, or (at your option) any later version.
  7. #
  8. # MikuInvidious is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with MikuInvidious. If not, see <http://www.gnu.org/licenses/>.
  15. import asyncio
  16. from aioflask import jsonify
  17. from danmaku import danmaku_xml_conv
  18. from xml.dom import minidom
  19. from bilibili_api import video
  20. from shared import *
  21. @app.route('/res/danmaku/<vid>:<idx>')
  22. async def danmaku_res(vid, idx=0):
  23. v = video.Video(bvid=vid)
  24. return jsonify(danmaku_xml_conv(minidom.parseString(await v.get_danmaku_xml(int(idx)))))