Esempio n. 1
0
    def __init__(self):
        self.logger = logging.getLogger('logentries')
        self.logger.setLevel(logging.INFO)

        logentries_token = settings.get_env_var("LOGENTRIES_TOKEN")
        self.logger.addHandler(LogentriesHandler(logentries_token))

        self.enabled = True
def convert(url):
    content = requests.get(url).content
    soup = BeautifulSoup(content, 'html.parser')

    for script in soup.find_all('script'):
        script_text = script.text

        if 'settings.bitrates' in script_text:
            regex = "settings.bitrates = {hls:\"//(.*?)\"}"
            search_result = re.compile(regex, 0).search(script_text)

            video_link = 'http://' + search_result.groups()[0]

            params = (
                ('url', video_link),
            )

            account = random.choice(ACCOUNTS)

            response = requests.get('https://api.streamable.com/import',
                                    params=params,
                                    auth=(account, settings.get_env_var('STREAMABLE_PASSWORD')))

            try:
                shortcode = response.json().get('shortcode')
            except JSONDecodeError:
                logger.log('Failed to create streamable video for: ' + url + ' | error: ' + response.text, forward=True)
                return None

            if shortcode:
                link = 'https://streamable.com/e/' + shortcode
                logger.log('New streamable video: ' + link + ' | for account: ' + account, forward=True)

                return link

    return None
Esempio n. 3
0
import re
import time

import dateparser
import requests

from fb_bot.highlight_fetchers.info import sources
from fb_bot.highlight_fetchers.utils.Highlight import Highlight
from highlights import settings

PART = "snippet"
CHANNEL_ID = "UCQsH5XtIc9hONE1BQjucM0g"
ORDER = "date"
MAX_RESULT = "50"
API_KEY = settings.get_env_var('YOUTUBE_KEY')
URL = "https://www.googleapis.com/youtube/v3/search?part={}&channelId={}&order={}&maxResults={}&key={}".format(
    PART, CHANNEL_ID, ORDER, MAX_RESULT, API_KEY)
YOUTUBE_LINK = "https://www.youtube.com/watch?v={}"


class YoutubeHighlight(Highlight):
    def __init__(self,
                 link,
                 match_name,
                 img_link,
                 view_count,
                 category,
                 time_since_added,
                 type='normal'):
        super().__init__(link,
                         match_name,
Esempio n. 4
0
from logentries import LogentriesHandler
import logging

from highlights import settings

LOGGER = logging.getLogger('logentries')
LOGGER.setLevel(logging.INFO)

logentries_token = settings.get_env_var("LOGENTRIES_TOKEN")
LOGGER.addHandler(LogentriesHandler(logentries_token))


def log(message):
    print(message)
    _send_to_logentries(message)


def log_for_user(message, user_id):
    message = "User: "******" | " + message
    print(message)
    _send_to_logentries(message)


def _send_to_logentries(log):
    if settings.is_prod():
        # Only send in production mode
        LOGGER.info(log)
Esempio n. 5
0
# API reference: https://cloudinary.com/documentation/image_upload_api_reference

import cloudinary.uploader
import cloudinary.api

from highlights import settings
from highlights.settings import PROD_STATUS

CLOUD_NAME = 'highlightsbot'
API_KEY = '618388125585167'
API_SECRET = settings.get_env_var('CLOUDINARY_SECRET')

TIMEOUT = 5  # 5s


def upload_image(url, public_id=None, overwrite=False):
    options = {
        'folder': '{}/highlights'.format(PROD_STATUS),
        'use_filename': False,
        'access_mode': 'public',
        'async': False,
        'overwrite': overwrite,
        'api_key': '618388125585167',
        'api_secret': 'zjJha4vr1rOuFLuIyeqFDyT_qRw',
        'cloud_name': 'highlightsbot'
    }

    if public_id:
        options['public_id'] = str(public_id)

    result = cloudinary.uploader.upload(url, timeout=TIMEOUT, **options)