mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-27 22:11:11 +00:00
Implemented youtube substitution
This commit is contained in:
parent
33b590c5f4
commit
3404b7df6a
16
twoot.py
16
twoot.py
|
@ -135,7 +135,6 @@ def _remove_trackers_fragment(fragment_str):
|
|||
:param query_str: fragment to be cleaned
|
||||
:return: cleaned fragment
|
||||
"""
|
||||
|
||||
params_to_remove = {
|
||||
"Echobox",
|
||||
}
|
||||
|
@ -147,6 +146,19 @@ def _remove_trackers_fragment(fragment_str):
|
|||
return fragment_str
|
||||
|
||||
|
||||
def _substitute_source(domain):
|
||||
"""
|
||||
private function
|
||||
param domain: Domain name to substitute
|
||||
:return: domain or sustitute if applicable
|
||||
"""
|
||||
youtube_subst = TOML["options"]["substitution"]["youtube"]
|
||||
if domain == 'youtube.com' and youtube_subst != []:
|
||||
domain = youtube_subst[random.randint(0, len(youtube_subst) - 1)]
|
||||
logging.debug("Replaced youtube.com by " + domain)
|
||||
|
||||
return domain
|
||||
|
||||
def clean_url(dirty_url):
|
||||
"""
|
||||
Given a URL, return it with the UTM parameters removed from query and fragment
|
||||
|
@ -160,7 +172,7 @@ def clean_url(dirty_url):
|
|||
|
||||
cleaned_url = urlunparse([
|
||||
url_parsed.scheme,
|
||||
url_parsed.netloc,
|
||||
_substitute_source(url_parsed.netloc),
|
||||
url_parsed.path,
|
||||
url_parsed.params,
|
||||
_remove_trackers_query(url_parsed.query),
|
||||
|
|
Loading…
Reference in New Issue
Block a user