diff --git a/searx/engines/bitchute.py b/searx/engines/bitchute.py new file mode 100644 index 000000000..88170c949 --- /dev/null +++ b/searx/engines/bitchute.py @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""bitchute (Videos)""" + +from json import dumps +from datetime import datetime +from searx.utils import html_to_text + +about = { + "website": 'https://bitchute.com', + "wikidata_id": "Q45287179", + "official_api_documentation": None, + "use_official_api": False, + "require_api_key": False, + "results": "JSON", +} + +base_url = "https://api.bitchute.com/api/beta/search/videos" +categories = ['videos'] +paging = True +results_per_page = 20 + + +def request(query, params): + + start_index = (params["pageno"] - 1) * results_per_page + data = {"offset": start_index, "limit": results_per_page, "query": query, "sensitivity_id": "normal", "sort": "new"} + params["url"] = base_url + params["method"] = 'POST' + params['headers']['content-type'] = "application/json" + params['data'] = dumps(data) + + return params + + +def response(resp): + search_res = resp.json() + results = [] + + for item in search_res.get('videos', []): + + results.append( + { + "title": item['video_name'], + "url": 'https://www.bitchute.com/video/' + item['video_id'], + "content": html_to_text(item['description']), + "author": item['channel']['channel_name'], + "publishedDate": datetime.strptime(item["date_published"], "%Y-%m-%dT%H:%M:%S.%fZ"), + "length": item['duration'], + "views": item['view_count'], + "thumbnail": item['thumbnail_url'], + "iframe_src": 'https://www.bitchute.com/embed/' + item['video_id'], + "template": "videos.html", + } + ) + + return results diff --git a/searx/settings.yml b/searx/settings.yml index a0b898448..dc9e6277a 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -560,6 +560,11 @@ engines: engine: bing_videos shortcut: biv + - name: bitchute + engine: bitchute + shortcut: bit + disabled: true + - name: bitbucket engine: xpath paging: true