From 86382706fe87afc63b2757a1a133497c75ce3cd2 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sun, 21 Jul 2019 22:28:57 -0700 Subject: Add flask Firefox search engine route --- youtube/search.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/youtube/search.py b/youtube/search.py index 76a814c..39a80bf 100644 --- a/youtube/search.py +++ b/youtube/search.py @@ -1,10 +1,12 @@ from youtube import util, yt_data_extract, proto, local_playlist from youtube import yt_app +import settings import json import urllib import base64 from math import ceil +import mimetypes from flask import request import flask @@ -124,4 +126,8 @@ def get_search_page(): parameters_dictionary = request.args, ) - +@yt_app.route('/opensearch.xml') +def get_search_engine_xml(): + with open("youtube/opensearch.xml", 'rb') as f: + content = f.read().replace(b'$port_number', str(settings.port_number).encode()) + return flask.Response(content, mimetype='application/xml') -- cgit v1.2.3