# this is an alternative to proxying through invidious. the search endpoint has only been (loosely) tested by #17:50 < perflyst[m]> appears to be working #, so i hopeā„¢ this works. if not, that's why it's in the 'dangerous' blueprint import requests from flask import Blueprint, render_template, request, flash, g, url_for from ..common.common import * from ..common.innertube import * from .lib import * frontend = Blueprint('dangerous', __name__, template_folder='templates', static_folder='static', static_url_path='/static/ys') @frontend.route('/search') def search(): #token = getattr(current_user, 'token', 'guest') q = request.args.get('q') page = int(request.args.get('page', 1)) sp = None #TODO: search filters (protobuf) # https://github.com/iv-org/invidious/blob/452d1e8307d6344dd51c5437ccd032a566291c34/src/invidious/search.cr#L266 if q: yt_results = fetch_searchresults(q, page, sp) results = prepare_searchresults(yt_results) else: results = None return render_template('search.html.j2', rows=results, query=q, page=page) @frontend.before_app_request def inject_button(): if not 'header_items' in g: g.header_items = [] g.header_items.append({ 'name': 'search', 'url': url_for('dangerous.search'), 'parent': frontend.name, 'priority': 15, })