Ejemplo n.º 1
0
    def get_text(self, status):
        result = []
        text = html_unescape(status.text.replace('\n', ' '))
        if status.rt:
            text = text.split(':')[1:]
            text = ':'.join(text)

        if hasattr(status, 'retweeted_status'):
            if hasattr(status.retweeted_status, 'text') \
                    and len(status.retweeted_status.text) > 0:
                text = status.retweeted_status.text

        myself = self.api.myself.screen_name

        words = text.split(' ')
        for word in words:
            if word != '':
                word += ' '
                # The word is an HASHTAG ? '#'
                if word[0] == '#':
                    result.append(('hashtag', word))
                elif word[0] == '@':
                    ## The AT TAG is,  @myself
                    if word == '@%s ' % myself or word == '@%s: ' % myself:
                        result.append(('highlight_nick', word))
                    ## @anyone
                    else:
                        result.append(('attag', word))
                        tyrs.container['completion'].add(get_exact_nick(word))

                else:
                    result.append(word)
        return result
Ejemplo n.º 2
0
Archivo: widget.py Proyecto: Nic0/tyrs
    def get_text(self, status):
        result = []
        text = html_unescape(status.text.replace("\n", " "))
        if status.rt:
            text = text.split(":")[1:]
            text = ":".join(text)

        if hasattr(status, "retweeted_status"):
            if hasattr(status.retweeted_status, "text") and len(status.retweeted_status.text) > 0:
                text = status.retweeted_status.text

        myself = self.api.myself.screen_name

        words = text.split(" ")
        for word in words:
            if word != "":
                word += " "
                # The word is an HASHTAG ? '#'
                if word[0] == "#":
                    result.append(("hashtag", word))
                elif word[0] == "@":
                    ## The AT TAG is,  @myself
                    if word == "@%s " % myself or word == "@%s: " % myself:
                        result.append(("highlight_nick", word))
                    ## @anyone
                    else:
                        result.append(("attag", word))
                        tyrs.container["completion"].add(get_exact_nick(word))

                else:
                    result.append(word)
        return result
Ejemplo n.º 3
0
    def get_text(self, status):
        result = []
        text = html_unescape(status.text.replace('\n', ' '))
        if status.rt:
            text = text.split(':')[1:]
            text = ':'.join(text)

        if hasattr(status, 'retweeted_status'):
            if hasattr(status.retweeted_status, 'text') \
                    and len(status.retweeted_status.text) > 0:
                text = status.retweeted_status.text

        myself = self.api.myself.screen_name

        words = text.split(' ')
        for word in words:
            if word != '':
                word += ' '
                # The word is an HASHTAG ? '#'
                if word[0] == '#':
                    result.append(('hashtag', word))
                elif word[0] == '@':
                    ## The AT TAG is,  @myself
                    if word == '@%s ' % myself or word == '@%s: ' % myself:
                        result.append(('highlight_nick', word))
                    ## @anyone
                    else:
                        result.append(('attag', word))
                        tyrs.container['completion'].add(get_exact_nick(word))
                        
                else:
                    result.append(word)
        return result
Ejemplo n.º 4
0
    def get_text(self, status):
        text = html_unescape(status.text.replace("\n", " "))
        if status.rt:
            text = text.split(":")[1:]
            text = ":".join(text)

            if hasattr(status, "retweeted_status"):
                if hasattr(status.retweeted_status, "text") and len(status.retweeted_status.text) > 0:
                    text = status.retweeted_status.text
        return text
Ejemplo n.º 5
0
    def get_text(self, status):
        text = html_unescape(status.text.replace('\n', ' '))
        if status.rt:
            text = text.split(':')[1:]
            text = ':'.join(text)

            if hasattr(status, 'retweeted_status'):
                if hasattr(status.retweeted_status, 'text') \
                        and len(status.retweeted_status.text) > 0:
                    text = status.retweeted_status.text
        return text
 def _get(self, url_page):
     id = get_id(url_page)
     html = downloader.read_html(url_page)
     soup = Soup(html)
     self.title = html_unescape(soup.find('title').text).replace(
         '- XVIDEOS.COM', '').strip()
     url = re.find(r'''.setVideoHLS\(['"](.+?)['"]\)''', html) or re.find(
         r'''.setVideoUrlHigh\(['"](.+?)['"]\)''', html) or re.find(
             r'''.setVideoUrlLow\(['"](.+?)['"]\)''',
             html)  #https://www.xvideos.com/video65390539/party_night
     if not url:
         raise Exception('no video url')
     ext = get_ext(url)
     if ext.lower() == '.m3u8':
         url = playlist2stream(url, n_thread=5, res=get_resolution())  #4773
     self.url_thumb = soup.find('meta', {
         'property': 'og:image'
     }).attrs['content']
     self.filename = format_filename(self.title, id, '.mp4')
     self._url = url
Ejemplo n.º 7
0
def find_url(html, url):
    href = re.findall('[\'"]([^\'"]+page.php[^\'"]+manga_detail[^\'"]+)[\'"]',
                      html)[0]
    href = html_unescape(href)
    return urljoin(url, href)
Ejemplo n.º 8
0
    post_timestamp = post.pub_date.strftime('%Y%m%d%H%M%S')
    json_index_content[post_timestamp] = {
        'title': post.title,
        'url': post.guid,
        'date': post.pub_date
    }

json_index_filtered = filter_json_index_by_year(json_index_content)

if not json_index_filtered:
    print('There are no posts to publish. Aborting.')
    sys.exit(0)

random_post_id = choice(list(json_index_filtered.keys()))
random_post_title = json_index_content[random_post_id]['title']
random_post_title = u(html_unescape(random_post_title))
random_post_url = u('{0}#{1}'.format(
    json_index_filtered[random_post_id]['url'], current_timestamp))

twitter_status = '{0} {1}'.format(random_post_title, random_post_url)

signature_timestamp = datetime.now().strftime('%s')
signature_once = str(getrandbits(64))
signature_basestr_auth = {}
signature_basestr_auth['status'] = twitter_status
signature_basestr_auth['oauth_consumer_key'] = twitter_consumer_key
signature_basestr_auth['oauth_nonce'] = signature_once
signature_basestr_auth['oauth_signature_method'] = twitter_api_method
signature_basestr_auth['oauth_timestamp'] = signature_timestamp
signature_basestr_auth['oauth_token'] = twitter_oauth_token
signature_basestr_auth['oauth_version'] = twitter_api_version
 def get_dn(cls, url):
     if url.startswith('magnet:'):
         qs = utils.query_url(url)
         if 'dn' in qs:
             return utils.html_unescape(qs['dn'][0])
Ejemplo n.º 10
0
TWITTER_API_VERSION = '1.0'
TWITTER_API_METHOD = 'HMAC-SHA1'
TWITTER_API_END = 'https://api.twitter.com/1.1/statuses/update.json'
TWITTER_CONSUMER_KEY = os.environ.get('TWITTER_CONSUMER_KEY')
TWITTER_CONSUMER_SECRET = os.environ.get('TWITTER_CONSUMER_SECRET')
TWITTER_OAUTH_TOKEN = os.environ.get('TWITTER_OAUTH_TOKEN')
TWITTER_OAUTH_SECRET = os.environ.get('TWITTER_OAUTH_SECRET')
FEED_URL = os.environ.get('FEED_URL')
FEED_DATA = parse_rss_bytes(urlopen(FEED_URL).read())

for post in FEED_DATA.items:

    ITEM_TIMESTAMP = int(post.pub_date.strftime('%Y%m%d%H%M%S'))
    LAST_TIMESTAMP = int(datetime.now().strftime('%Y%m%d%H%M%S')) - 10000
    ITEM_TITLE = u(html_unescape(post.title))
    ITEM_LINK = u(post.guid)
    TWITTER_STATUS = ITEM_TITLE + ' ' + ITEM_LINK

    if ITEM_TIMESTAMP >= LAST_TIMESTAMP:

        SIGNATURE_TIMESTAMP = datetime.now().strftime('%s')
        SIGNATURE_ONCE = base64.b64encode(
            s(''.join([str(random.randint(0, 9)) for i in range(24)])))
        SIGNATURE_BASE_STRING_AUTH = 'oauth_consumer_key=' + escape(
            TWITTER_CONSUMER_KEY)
        SIGNATURE_BASE_STRING_AUTH += '&oauth_nonce=' + escape(SIGNATURE_ONCE)
        SIGNATURE_BASE_STRING_AUTH += '&oauth_signature_method=' + escape(
            TWITTER_API_METHOD)
        SIGNATURE_BASE_STRING_AUTH += '&oauth_timestamp=' + escape(
            SIGNATURE_TIMESTAMP)