diff --git a/app/request.py b/app/request.py index 471f4f4..aebc716 100644 --- a/app/request.py +++ b/app/request.py @@ -1,6 +1,6 @@ -from app import rhyme from io import BytesIO import pycurl +import random import urllib.parse as urlparse # Base search url @@ -16,9 +16,9 @@ VALID_PARAMS = ['tbs', 'tbm', 'start', 'near'] def gen_user_agent(normal_ua): is_mobile = 'Android' in normal_ua or 'iPhone' in normal_ua - mozilla = rhyme.get_rhyme('Mo') + rhyme.get_rhyme('zilla') - firefox = rhyme.get_rhyme('Fire') + rhyme.get_rhyme('fox') - linux = rhyme.get_rhyme('Lin') + 'ux' + mozilla = random.choice(['Moo', 'Woah', 'Bro', 'Slow']) + 'zilla' + firefox = random.choice(['Choir', 'Squier', 'Higher', 'Wire']) + 'fox' + linux = random.choice(['Win', 'Sin', 'Gin', 'Fin', 'Kin']) + 'ux' if is_mobile: return MOBILE_UA.format(mozilla, firefox) diff --git a/app/rhyme.py b/app/rhyme.py deleted file mode 100644 index 23b9137..0000000 --- a/app/rhyme.py +++ /dev/null @@ -1,25 +0,0 @@ -import itertools -from Phyme import Phyme -import random -import sys -import time - -random.seed(time.time()) - -ph = Phyme() - - -def get_rhyme(word): - # Get all rhymes and merge to one list (normally separated by syllable count) - rhymes = ph.get_perfect_rhymes(word) - rhyme_vals = list(itertools.chain.from_iterable(list(rhymes.values()))) - - # Pick a random rhyme and strip out any non alpha characters - rhymed_word = rhyme_vals[random.randint(0, len(rhyme_vals) - 1)] - rhymed_word = ''.join(letter for letter in rhymed_word if letter.isalpha()) - - return rhymed_word.capitalize() - - -if __name__ == '__main__': - print(get_rhyme(sys.argv[1])) diff --git a/requirements.txt b/requirements.txt index 02e43ce..5a6a937 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,6 @@ Flask==1.1.1 itsdangerous==1.1.0 Jinja2==2.10.3 MarkupSafe==1.1.1 -Phyme==0.0.9 pycparser==2.19 pycurl==7.43.0.4 pyOpenSSL==19.1.0