Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, re, random, os, mimetypes,json
- from lxml.html import fromstring
- def retro(sfondo, font, testo1, testo2, testo3):
- # sfondo: 1,2,3,4,5
- # font: 1,2,3,4
- # testo max 15 caratteri
- #crea un immagine 'retro' a partire da un testo
- headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0'}
- data = {'current-category': 'all_effects', 'bcg': sfondo, 'txt': font, 'text1': testo1, 'text2': testo2, 'text3': testo3}
- r = requests.post('https://photofunia.com/categories/all_effects/retro-wave?server=3', data=data, headers=headers)
- links = fromstring(r.text).xpath('//a[normalize-space() = "Large"]/@href')
- link = links[0][:-9] if len(links) > 0 else None
- return link
- def owo(testo):
- #ritorna desto owoificato
- facce = ['(・`ω´・)', ';;w;;', 'owo', 'UwU', '>w<', '^w^']
- testo = re.sub('[rl]', 'w', testo)
- testo = re.sub('[RL]', 'W', testo)
- testo = re.sub('n([aeiou]+)', r'ny\1', testo)
- testo = re.sub('N([aeiou]+)', r'Ny\1', testo)
- testo = re.sub('N([AEIOU]+)', r'Ny\1', testo)
- testo = re.sub('ove', 'uv', testo)
- testo = re.sub('!+', ' ' + random.choice(facce) + ' ', testo)
- return testo
- def aesthetics(testo):
- #ritorna testo con effetto vaporwave
- lista_asiatici = """リサフランク現代のコンピュ竹内 まりや若者が履く流行のスニーカー真夜中のドアホットドッグマスターストライカーソニ
- ーブギ新しい日の誕生ライフ - ヒスイ蒸気波 無線゠ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネ
- ノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ーヽヾヿぁあぃいぅうぇえぉおかがきぎくぐけげこご
- さざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんゔゕゖ゙゚゛゜
- ゝゞゟ亜哀挨愛曖悪握圧扱宛嵐安案暗以衣位囲医依委威為畏胃尉異移萎偉椅彙意違維慰遺緯域育壱逸茨芋引印因咽姻員院淫陰飲隠韻右宇羽雨唄鬱畝浦運雲永
- 泳英映栄営詠影鋭衛易疫益液駅悦越謁閲円延沿炎怨宴媛援園煙猿遠鉛塩演縁艶汚王凹央応往押旺欧殴桜翁奥横岡屋億憶臆虞乙俺卸音恩温穏下化火加可仮何花
- 佳価果河苛科"""
- n = max(3, len(testo.split()))
- return "".join(x if not ord(x) in range(33, 127) else chr(ord(x) + 65248) for x in testo) + " " + \
- "".join(random.choice(lista_asiatici) for y in range(n))
- def flip_testo(testo):
- #ribalta testo
- testo = testo.lower()
- alfabeto = {'a': 'ɐ', 'b': 'q', 'c': 'ɔ', 'd': 'p', 'e': 'ǝ', 'f': 'ɟ', 'g': 'b', 'h': 'ɥ', 'i': 'ı', 'j': 'ظ',
- 'k': 'ʞ', 'l': 'ן', 'm': 'ɯ', 'n': 'u', 'o': 'o', 'p': 'd', 'q': 'b', 'r': 'ɹ', 's': 's', 't': 'ʇ',
- 'u': 'n', 'v': 'ʌ', 'w': 'ʍ', 'x': 'x', 'y': 'ʎ', 'z': 'z', '[': ']', ']': '[', '(': ')', ')': '(',
- '{': '}', '}': '{', '?': '¿', '¿': '?', '!': '¡', '\'': ',', ',': '\'', '.': '˙', '_': '‾', ';': '؛',
- '9': '6', '6': '9'}
- return "".join(alfabeto.get(x, x) for x in testo[::-1])
- def rip(testo1, nome='R.I.P.', testo2='Hopes and Dreams'):
- #crea tomba personalizzata partendo da un testo
- return 'http://www.tombstonebuilder.com/generate.php?top1={0}&top3={1}&top4={2}'.format(nome, testo1, testo2)
- def minecraft(nome, testo):
- #crea achievement di minecraft personalizzato partendo da un testo
- return 'https://mcgen.herokuapp.com/a.php?i=1&h=Achievement-{0}&t={1}'.format(nome, testo)
- def tono(testo):
- #analizza le emozioni presenti in un testo
- data = {'text': testo, 'language': 'en'}
- headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0.2 Waterfox/46.0.2'}
- json = requests.post('https://tone-analyzer-demo.ng.bluemix.net/api/tone', data=data, headers=headers).json()
- toni = json['document_tone']['tones']
- if len(toni) == 0:
- return None
- return [tono['tone_name'] for tono in toni if tono['score'] >= 0.75]
- def identifica(img_path):
- #identifica un'immagine
- s = requests.Session()
- mime = mimetypes.guess_type(img_path)[0]
- name = os.path.basename(img_path)
- files = {'file': (name, open(img_path, 'rb'), mime)}
- risp = s.post('https://www.captionbot.ai/api/upload', files=files)
- url_immagine = risp.text[1:-1]
- data = {'Content': url_immagine, 'Type': 'CaptionRequest'}
- headers = {'Content-Type': 'application/json; charset=utf-8'}
- risp = s.post('https://captionbot.azurewebsites.net/api/messages', data=json.dumps(data), headers=headers)
- if not risp.ok:
- return None
- messaggio = risp.text[1:-1].replace('\\"', '"').replace('\\n', '\n')
- return messaggio
- def smart(testo):
- #scarica file e apri in locale
- json = requests.get('https://honk.moe/tools/thesaurus.json').json()
- stop = {'ourselves', 'hers', 'between', 'yourself', 'but', 'again', 'there', 'about', 'once', 'during', 'out',
- 'having', 'with', 'they', 'own', 'an', 'be', 'some', 'for', 'do', 'its', 'yours', 'such', 'into', 'of',
- 'most', 'itself', 'other', 'off', 'is', 's', 'am', 'or', 'who', 'as', 'from', 'him', 'each', 'the',
- 'themselves', 'until', 'below', 'are', 'we', 'these', 'your', 'his', 'through', 'don', 'nor', 'me', 'were',
- 'her', 'more', 'himself', 'this', 'down', 'should', 'our', 'their', 'while', 'above', 'both', 'up', 'to',
- 'ours', 'had', 'she', 'all', 'no', 'when', 'at', 'any', 'before', 'them', 'same', 'and', 'been', 'have',
- 'in', 'will', 'on', 'does', 'yourselves', 'then', 'that', 'because', 'what', 'over', 'why', 'so', 'can',
- 'did', 'not', 'now', 'under', 'he', 'you', 'herself', 'has', 'just', 'where', 'too', 'only', 'myself',
- 'which', 'those', 'i', 'after', 'few', 'whom', 't', 'being', 'if', 'theirs', 'my', 'against', 'a', 'by',
- 'doing', 'it', 'how', 'further', 'was', 'here', 'than', 'get', 'go'}
- testo = testo.lower()
- parole = testo.split(' ')
- messaggio = ''
- for parola in parole:
- if parola not in stop:
- parola = json.get(parola) if json.get(parola) is not None else parola
- messaggio += parola + " "
- return ''.join(frase.capitalize() for frase in re.split('([.!?] )', messaggio))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement