Exemple #1
0
def trigger(topic=None, details=None):
    key = config_parser.read_config().get('ifttt', 'key')
    url = "https://maker.ifttt.com/trigger/" + str(
        details) + "/with/key/" + str(key)
    ahlogger.log(url)
    r = requests.post(url)
    ahlogger.log(r.status_code)
def send_http_requuest(url, params, type):
    ahlogger.log("sending http request")

    r = requests.get(url)
    if (r.status_code == 200):
        return json.loads(r.text)
    r.status_code
def send_download_request(i):
    p = subprocess.Popen(
        'ssh -t [email protected] python /home/nani/work/getYoutube_playlist.py',
        shell=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT)
    for line in p.stdout.readlines():
        ahlogger.log(line, end=' ')
    retval = p.wait()
def get_telugu_list():
    base_url = 'http://www.movierulz.ms/telugu-movie/'
    r = requests.get(base_url)
    soup = BeautifulSoup(r.text, "lxml")

    for tag in soup.find_all("dd"):
        if (isinstance(tag, Tag) & ('class' in tag.attrs)):
            if ('wp-caption-text' in tag.attrs['class']):
                test = tag.contents[0]
                ahlogger.log(test.replace("(Telugu)", "").strip())
def getSkyTorrentMagent(title, year):
    base_url = "https://www.skytorrents.in"
    q_string = urllib.parse.urlencode({'q': title + ' ' + year})
    url = str(base_url) + "/search/all/ed/1/?l=en-us&" + q_string
    ahlogger.log(url)
    r = requests.get(url)
    soup = BeautifulSoup(r.text, "lxml")
    for tag in soup.find_all("td"):
        a = tag.contents
        for each_c in a:
            if isinstance(each_c, Tag):
                if hasattr(each_c, 'attrs'):
                    if "href" in each_c.attrs:
                        test = each_c.attrs['href']
                        if str(test).find("magnet:") != -1:
                            return each_c.attrs['href']
def get_credentials():
    home_dir = os.path.expanduser('~')
    credential_dir = os.path.join(home_dir, '.credentials')
    if not os.path.exists(credential_dir):
        os.makedirs(credential_dir)
    credential_path = os.path.join(credential_dir,
                                   'calendar-python-quickstart.json')

    store = Storage(credential_path)
    credentials = store.get()
    if not credentials or credentials.invalid:
        flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
        flow.user_agent = APPLICATION_NAME
        if flags:
            credentials = tools.run_flow(flow, store, flags)
        else:  # Needed only for compatibility with Python 2.6
            credentials = tools.run(flow, store)
        ahlogger.log('Storing credentials to ' + credential_path)
    return credentials
def process_message(topic=None, message=None):
    # TODO: need to fix the dynamic loading of modules
    try:
        ahlogger.log("topic: " + topic)
        ahlogger.log("status " + str(message))

        if ("tv" in topic):
            module = tv
        if ("ifttt" in topic):
            module = ifttt
        if ("firetv" in topic):
            module = firetv
        if ("dash" in topic):
            module = dash
        if ("volumio" in topic):
            module = volumio
        if ("alerts" in topic):
            module = alerts
        if ("audio" in topic):
            module = audio

        func = getattr(module, topic.split("/")[2])
        func(topic, message)

    except:
        ahlogger.log("Cannto find service")
Exemple #8
0
def playlist(topic=None, details=None):
    ip = None
    all_details = json.loads(details)

    ip = all_details.get('ip')
    name = all_details.get('playlist')

    url = "http://" + str(
        ip) + "/api/v1/commands/?cmd=playplaylist&name=" + str(name)
    ahlogger.log(url)
    r = requests.get(url)
    ahlogger.log(r.status_code)

    ahlogger.log("")
def download_title(title):

    ahlogger.log("get actual name")
    # get torrent file
    details = send_http_requuest(
        "https://api.themoviedb.org/3/search/movie?api_key=&query=" + title, 0,
        0)
    title = details['results'][0]['title']
    year = details['results'][0]['release_date'].split('-')[0]
    ahlogger.log(title + " " + year)
    t_magent = getSkyTorrentMagent(title, year)
    tc = transmissionrpc.Client('192.168.0.17',
                                port=9091,
                                user='******',
                                password='******')
    tc.add_torrent(t_magent)
    ahlogger.log(tc.get_torrents())

    # need to get the torrents link
    return "adding title " + title + "to transmissions"
Exemple #10
0
@ask.intent('NEXTEVENTS')
def getTeluguMovieList():
    ahlogger.log("getting next events")
    response = calendar_service.get_home_controller_events()
    return statement(response).simple_card('PCOFF', response)


@ask.session_ended
def session_ended():
    return "{}", 200


def alexa_launch():
    if 'ASK_VERIFY_REQUESTS' in os.environ:
        verify = str(os.environ.get('ASK_VERIFY_REQUESTS', '')).lower()
        if verify == 'false':
            app.config['ASK_VERIFY_REQUESTS'] = False
    app.run(debug=True)


if __name__ == '__main__':
    jobs = []
    # p = Process(target=alexa_launch)
    # p.start()

    p1 = Process(target=launcher.start_process("192.168.0.14"), args=('bob', ))
    p1.start()

    ahlogger.log("STARTING ALEXA")
Exemple #11
0
def kodi(topic=None, details=None):
    ## turm on tv
    RMBroadLInk().toggle_power()
    time.sleep(10)
    FireStick().turn_on_kodi()
    ahlogger.log("in tv platform")
Exemple #12
0
def getTeluguMovieList():
    ahlogger.log("getting next events")
    response = calendar_service.get_home_controller_events()
    return statement(response).simple_card('PCOFF', response)
Exemple #13
0
 def shutdown(self):
     output = Utils.execute_remote_command(self.ip, self.username, self.password, self.shutdown_cmd)
     ahlogger.log(output)
Exemple #14
0
def getMovie(GetMovie):
    ahlogger.log("MESAGE FROM ALEXA HOME")
    ahlogger.log(("*******" + GetMovie + "**********"))
    response = media_downloader.download_title(GetMovie)
    speech_text = 'Adding title ' + GetMovie + "to transmissions"
    return statement(speech_text).simple_card('PCOFF', speech_text)
Exemple #15
0
def getTeluguMovieList():
    ahlogger.log("MESAGE FROM ALEXA HOME")
    response = media_downloader.get_telugu_list()
    speech_text = 'Rarandoi Veduka Chudham'
    return statement(speech_text).simple_card('PCOFF', speech_text)
Exemple #16
0
def getTeluguMovieList():
    ahlogger.log("Downloading your youtube playlist")
    response = media_downloader.download_youtube_playlist()
    return statement(response).simple_card('PCOFF', response)
Exemple #17
0
def read_config():
    config = configparser.ConfigParser()
    ahlogger.log((config.sections()))
    config.read(os.path.expanduser('~') + '/work/alexa_settings.ini')
    return config
Exemple #18
0
def send(topic, message):
    ahlogger.log("sending " + message + " to " + topic)
    publish.single(topic, message, hostname="192.168.0.14")
Exemple #19
0
def read_config():
    config = configparser.ConfigParser()
    config.read(os.path.expanduser('~') + '/home_settings.ini')
    ahlogger.log(config.sections())
    return config
Exemple #20
0
def daily(topic=None, details=None):
    config = config_parser.read_config()
    alerts = list(config.items('alerts'))
    now = datetime.datetime.now()
    messages = []

    for x in alerts:
        date = str(x[1])
        event_month = int(int(date.split("/")[1]))
        event_day = int(int(date.split("/")[0]))
        each_message = ""
        message_time = ""

        if (int(now.month) == event_month):

            if (int(now.day) == event_day):
                message_time += "Today"

            if ((int(now.day) + 1) == event_day):
                message_time += "Tomorrow"

        if (message_time != ""):
            message_event = ""
            key = str(x[0])
            message_event += "Its " + key.replace("_",
                                                  " ") + " " + message_time
            messages.append(message_event)

    if len(messages) > 0:

        for each_message in messages:
            body = json.dumps({
                "notification": each_message,
                "accessCode": config.get('notify_me', 'api_key')
            })
            requests.post(url="https://api.notifymyecho.com/v1/NotifyMe",
                          data=body)
            headers = {
                "Access-Token": "o.Qiiw4SPAmxx3GbBxZDRO5XpYFcdgtBTq",
                "Content-Type": "application/json"
            }
            body = json.dumps({
                "body": each_message,
                "title": 'Travis Reminder'
            })
            requests.post(url="https://api.pushbullet.com/v2/pushes",
                          data=body,
                          headers=headers)

            ACCESS_TOKEN = config.get('push_bullet', 'access_token')
            headers = {
                'Authorization': 'Bearer ' + ACCESS_TOKEN,
                'Content-Type': 'application/json'
            }
            body = json.dumps({
                'body': each_message,
                'title': 'Travis Reminder',
                'type': 'note'
            })
            response = requests.post(
                url="https://api.pushbullet.com/v2/pushes",
                data=body,
                headers=headers)
            ahlogger.log(response)
            ahlogger.log(each_message)