def saveButton_onclick(button): ### validation of the fields username = tb_username.get_edit_text() password = tb_password.get_edit_text() url = tb_url.get_edit_text() parallelProcesses = tb_parallelProcesses.get_edit_text() if len(str(username)) < 3: self.messageBox( "Input Error", "Junos Space Username needs to have at least 3 charcters!") return if len(str(password)) < 3: self.messageBox( "Input Error", "Junos Space Password needs to have at least 3 charcters!") return if len(str(url)) == 0: self.messageBox( "Input Error", "The Junos Space URL needs to have at least 3 charcters and begin with http:// or https:// !" ) return if len(str(parallelProcesses)) == 0: self.messageBox( "Input Error", "The number of parallel processes cannot be left empty!") return if not utils.validateParalellProcessNumber(parallelProcesses): self.messageBox( "Input Error", "The given number of parallel processes is not valid!\nExpected values are between 0 - 25. " ) return if not utils.validateUrl(url): self.messageBox( "Input Error", "The Junos Space URL needs to be a valid http/https URL.") return #### saving the settings to disk try: data = {} data["username_js"] = username data["password_js"] = password data["url"] = url data["parallelProcesses"] = parallelProcesses with open("conf/SNSIFetcher.conf", 'w') as f: f.write(json.dumps(data, indent=4, sort_keys=True)) self.messageBox("Settings", "Settings have been saved succesfull!") except: self.messageBox( "Settings > Error", "There were errors while attempting to save the settings to disk.\nPlease check permissions rights and/or locks for file: directFetcher.conf" )
def what_is(m): search_for = m.group(1).split("?")[0] sq = search_for.split(" ") sq = "+".join(sq) url = "https://lmgtfy.com/?q=" + sq if utils.validateUrl(url): return url
def process(query): feed = utils.Feedback() try: if utils.validateUrl(query) and 'playlist?list' in query: feed.add_item('Download Playlist Video', query, "{'node':%s,'url':\'%s\'}" % ('1', query), '', '', 'Icons/_playlist.png') feed.add_item('Download Playlist Audio', query, "{'node':%s, 'url':\'%s\'}" % ('2', query), '', '', 'Icons/_playlist.png') else: feed.add_item('No Download', 'Invalid playlist URL', '', '', '', 'Icons/_x.png') except ValueError: feed.add_item('Invalid URL', 'No playlist could be found at %s' % query, '', '', '', 'Icons/_x.png') print feed
def process(query): f = utils.Feedback() try: if utils.validateUrl(query) and 'soundcloud' in utils.checkDomain(query) and 'sets' in urlparse.urlparse(query).path.split('/')[2].lower(): f.add_item('Download Playlist Audio', query, "{'node':%s,'url':\'%s\'}" % ('2', query), '', '', 'Icons/_audio.png') elif utils.validateUrl(query) and 'youtube' in utils.checkDomain(query) and 'playlist' in urlparse.urlparse(query).path.lower(): f.add_item('Download Playlist Video', query, "{'node':%s,'url':\'%s\'}" % ('1', query), '', '', 'Icons/_video.png') f.add_item('Download Playlist Audio', query, "{'node':%s,'url':\'%s\'}" % ('2', query), '', '', 'Icons/_audio.png') else: f.add_item('No Download', 'Invalid playlist URL', '', '', '', 'Icons/_x.png') print f except ValueError: client = soundcloud.Client(client_id = utils.SOUNDCLOUD_API) playlistsSoundCloud = client.get('/playlists', q = query, limit = 9) playlistsYouTube = [] urlValid = 'https://gdata.youtube.com/feeds/api/playlists/snippets?v=2&q=%s&max-results=9' % query for i in minidom.parseString(urllib.urlopen(urlValid).read()).getElementsByTagName('entry'): newList = {} domTitle = i.getElementsByTagName('link')[1].getAttribute('href') domDescription = i.getElementsByTagName('summary')[0].firstChild domName = i.getElementsByTagName('author')[0].firstChild.firstChild.nodeValue if domDescription is not None: domDescription = domDescription.data newList['title'] = domTitle newList['description'] = domDescription newList['name'] = domName playlistsYouTube.append(newList) increment = 0 while increment < len(playlistsYouTube): try: f.add_item(playlistsYouTube[increment]['name'], playlistsYouTube[increment]['description'], playlistsYouTube[increment]['title'], '', '', 'Icons/_youtube.png') except IndexError: pass try: f.add_item(playlistsSoundCloud[increment].title, playlistsSoundCloud[increment].description, playlistsSoundCloud[increment].permalink_url, '', '', 'Icons/_soundcloud.png') except IndexError: pass increment += 1 print f
def shortenUrl(): body = request.get_json() if not validateUrl(body['url']): res = {'message': 'Invalid url in request body'} return jsonify(res), 400 hashObject = hashlib.md5(body['url'].encode()) urlHash = hashObject.hexdigest() if 'truncate' in body: urlHash = urlHash[:10] table.put_item( Item={ 'url_hash': urlHash, 'url': body['url'], 'created_at': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") }) res = {'id': urlHash, 'shortened_url': SERVER_DNS + '/' + urlHash} return jsonify(res), 201
try: if len(data.split()) >= 3: channel = data.split()[2] splitter = "PRIVMSG " + channel + " :" msg = splitter.join(data.split(splitter)[1:]) for cmd in utils.regex_commands: for reg in cmd: m = re.match(reg, msg, flags=re.IGNORECASE) if m: result = cmd[reg](m) if result: send_message(result, channel) continue for word in msg.split(" "): if len(word) < 6: continue result = None word = word.strip() if word[-1] in [" ", "?", ",", ";", ":", "\\"]: word = word[:-1] if utils.validateUrl(word): result = utils.url_commands[-1](word) if result: send_message(result, channel) except Exception as e: log("ERROR IN MAINLOOP: ", e) s.close()