diff --git a/metaproxy.py b/metaproxy.py index a1632d2..3f70781 100644 --- a/metaproxy.py +++ b/metaproxy.py @@ -28,8 +28,8 @@ def get_metalink(): # Parse the .env file to get the filtering criteria excluded_countries = eval(os.getenv('EXCLUDED_COUNTRIES', '[]')) - preferred_protocols = eval(os.getenv('PREFERRED_PROTOCOLS', '[]')) - preferred_types = eval(os.getenv('PREFERRED_TYPES', '[]')) + preferred_protocols = eval(os.getenv('PREFERRED_PROTOCOLS', '["https", "http"]')) + preferred_types = eval(os.getenv('PREFERRED_TYPES', '["https", "http"]')) min_preference = int(os.getenv('MIN_PREFERENCE', '0')) # Filter out the URLs based on the criteria @@ -58,8 +58,11 @@ def filter_urls(content, excluded_countries, preferred_protocols, preferred_type preference < min_preference): url.decompose() - # Return the filtered XML as a string - return str(soup) + # Convert the BeautifulSoup object back to a string and clean up + filtered_content = str(soup) + filtered_content = '\n'.join(line for line in filtered_content.splitlines() if line.strip()) + + return filtered_content if __name__ == '__main__': app.run(debug=True)