コード例 #1
0
ファイル: get_stories.py プロジェクト: peaches69/snapy
def main():
    arguments = docopt(__doc__)
    quiet = arguments['--quiet']
    unzip = arguments['--unzip']

    username = arguments['--username']

    auth_token = arguments['--auth-token']

    gmail = arguments['--gmail']
    if arguments['--gpasswd'] is None:
        gpasswd = getpass('Gmail password:'******'--gpasswd']

    path = arguments['<path>']

    if not os.path.isdir(path):
        print('No such directory: {0}'.format(arguments['<path>']))
        sys.exit(1)

    s = Snapchat()

    if auth_token:
        s.restore_token(username, auth_token, gmail, gpasswd)

    else:
        if arguments['--password'] is None:
            password = getpass('Password:'******'--password']

        if not s.login(username, password, gmail,
                       gpasswd)['updates_response'].get('logged'):
            print('Invalid username or password')
            sys.exit(1)

    for snap in s.get_friend_stories():
        filename = '{0}.{1}'.format(snap['id'],
                                    get_file_extension(snap['media_type']))
        abspath = os.path.abspath(os.path.join(path, filename))

        if os.path.isfile(abspath):
            continue

        data = s.get_story_blob(snap['media_id'], snap['media_key'],
                                snap['media_iv'])
        if data is None:
            continue

        with open(abspath, 'wb') as f:
            f.write(data)
            if not quiet:
                print('Saved: {0}'.format(abspath))

        if is_zipfile(abspath) and unzip:
            unzip_snap_mp4(abspath, quiet)
コード例 #2
0
ファイル: get_stories.py プロジェクト: peaches69/snapy
def main():
    arguments = docopt(__doc__)
    quiet = arguments['--quiet']
    unzip = arguments['--unzip']

    username = arguments['--username']

    auth_token = arguments['--auth-token']

    gmail = arguments['--gmail']
    if arguments['--gpasswd'] is None:
        gpasswd = getpass('Gmail password:'******'--gpasswd']

    path = arguments['<path>']

    if not os.path.isdir(path):
        print('No such directory: {0}'.format(arguments['<path>']))
        sys.exit(1)

    s = Snapchat()

    if auth_token:
        s.restore_token(username, auth_token, gmail, gpasswd)

    else:
        if arguments['--password'] is None:
            password = getpass('Password:'******'--password']

        if not s.login(username, password, gmail, gpasswd)['updates_response'].get('logged'):
            print('Invalid username or password')
            sys.exit(1)

    for snap in s.get_friend_stories():
        filename = '{0}.{1}'.format(snap['id'],
                                    get_file_extension(snap['media_type']))
        abspath = os.path.abspath(os.path.join(path, filename))

        if os.path.isfile(abspath):
            continue

        data = s.get_story_blob(snap['media_id'],
                                snap['media_key'],
                                snap['media_iv'])
        if data is None:
            continue

        with open(abspath, 'wb') as f:
            f.write(data)
            if not quiet:
                print('Saved: {0}'.format(abspath))

        if is_zipfile(abspath) and unzip:
            unzip_snap_mp4(abspath, quiet)
コード例 #3
0
ファイル: get_snaps.py プロジェクト: peaches69/snapy
def main():
    arguments = docopt(__doc__)
    quiet = arguments['--quiet']
    unzip = arguments['--unzip']
    username = arguments['--username']
    
    auth_token = arguments['--auth-token']
    
    gmail = arguments['--gmail']
    if arguments['--gpasswd'] is None:
        gpasswd = getpass('Gmail password:'******'--gpasswd']

    path = arguments['<path>']

    if not os.path.isdir(path):
        print('No such directory: {0}'.format(arguments['<path>']))
        sys.exit(1)

    s = Snapchat()

    if auth_token:
        s.restore_token(username, auth_token, gmail, gpasswd)

    else:
        if arguments['--password'] is None:
            password = getpass('Password:'******'--password']

        if not s.login(username, password, gmail, gpasswd)['updates_response'].get('logged'):
            print('Invalid username or password')
            sys.exit(1)

    for snap in s.get_snaps():
        process_snap(s, snap, path, quiet, unzip)
コード例 #4
0
ファイル: snapfeed.py プロジェクト: matthazinski/snapfeed
def main():
    arguments = docopt(__doc__)

    # These are common to everything
    whitelist = arguments['<whitelist>']
    path = arguments['<path>']
    base_url = arguments['--base-url']
    
    if arguments['--regenerate-html']:
        print('Regenerating HTML!')
        for user in whitelist:
            gen_html_archives(user, base_url, path)
        sys.exit(1)

    # Arguments after this are specific to logging in
    username = arguments['--username']
    gmail = arguments['--gmail']

    if arguments['--gpasswd'] is None:
        gpasswd = getpass('Gmail password:'******'--gpasswd']

    if arguments['--delay'] is None:
        delay = 60
    else:
        delay = int(arguments['--delay'])

    auth_token = arguments['--auth-token']


    if not os.path.isdir(path):
        print('No such directory: {0}'.format(arguments['<path>']))
        sys.exit(1)
    
    s = Snapchat()

    if auth_token:
        s.restore_token(username, auth_token, gmail, gpasswd)

    else:
        if arguments['--password'] is None:
            password = getpass('Password:'******'--password']

        if not s.login(username, password, gmail, gpasswd)['updates_response'].get('logged'):
            print('Invalid username or password')
            sys.exit(1)

       
    # Every N minutes, fetch new snaps and generate a new feed
    while True:
        check_snaps(s, path, whitelist, base_url)

        for u in whitelist:
            gen_feed(u, base_url, path)

            # Use UTC time for everyting because snapchat has Unix timestamps
            todayDate = datetime.datetime.utcnow()
            
            # The beginning of today (midnight)
            todayDt = datetime.datetime(todayDate.year, todayDate.month, todayDate.day, 0,0,0)
            gen_html_page(u, todayDt, base_url, path)

        
        time.sleep(delay*60)
コード例 #5
0
ファイル: snapfeed.py プロジェクト: matthazinski/snapfeed
def main():
    arguments = docopt(__doc__)

    # These are common to everything
    whitelist = arguments['<whitelist>']
    path = arguments['<path>']
    base_url = arguments['--base-url']

    if arguments['--regenerate-html']:
        print('Regenerating HTML!')
        for user in whitelist:
            gen_html_archives(user, base_url, path)
        sys.exit(1)

    # Arguments after this are specific to logging in
    username = arguments['--username']
    gmail = arguments['--gmail']

    if arguments['--gpasswd'] is None:
        gpasswd = getpass('Gmail password:'******'--gpasswd']

    if arguments['--delay'] is None:
        delay = 60
    else:
        delay = int(arguments['--delay'])

    auth_token = arguments['--auth-token']

    if not os.path.isdir(path):
        print('No such directory: {0}'.format(arguments['<path>']))
        sys.exit(1)

    s = Snapchat()

    if auth_token:
        s.restore_token(username, auth_token, gmail, gpasswd)

    else:
        if arguments['--password'] is None:
            password = getpass('Password:'******'--password']

        if not s.login(username, password, gmail,
                       gpasswd)['updates_response'].get('logged'):
            print('Invalid username or password')
            sys.exit(1)

    # Every N minutes, fetch new snaps and generate a new feed
    while True:
        check_snaps(s, path, whitelist, base_url)

        for u in whitelist:
            gen_feed(u, base_url, path)

            # Use UTC time for everyting because snapchat has Unix timestamps
            todayDate = datetime.datetime.utcnow()

            # The beginning of today (midnight)
            todayDt = datetime.datetime(todayDate.year, todayDate.month,
                                        todayDate.day, 0, 0, 0)
            gen_html_page(u, todayDt, base_url, path)

        time.sleep(delay * 60)