Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def yosurlinput(match, nick='', chan='', db=None, bot=None):
- db_init(db)
- chan = chan.strip('#')
- url = urlnorm.normalize(match.group().encode('utf-8'))
- if url not in ignored_urls:
- url = url.decode('utf-8')
- a = urllib.urlopen(url)
- statusCode = a.getcode()
- if statusCode == 200:
- urlRequest = urllib2.urlopen(HeadRequest(url))
- urlRequest2 = urlRequest.info()
- urlType = urlRequest2.getmaintype()
- if urlType == "text":
- getHtml = http.get_html(url)
- getTitle = getHtml.xpath('//title/text()')[0]
- if getTitle.split()[0] == "YouTube":
- category = "youtube"
- else:
- category = "website"
- insert_yosurl(db, chan, url, nick, category, getTitle)
- if urlType == "audio":
- category = "audio"
- title = "Audio File"
- insert_yosurl(db, chan, url, nick, category, title)
- if urlType == "image":
- category = "image"
- title = "Image File"
- insert_yosurl(db, chan, url, nick, category, title)
- else:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement