Beispiel #1
0
    def GET(self):
        access_token = sess.obtain_access_token(REQUEST_TOKEN)
        allowed_client = client.DropboxClient(sess)

        # 1: get dropbox account info.
        userdata = allowed_client.account_info()

        # preset for mongo
        connection = Connection()
        db = connection.simplyime

        # 2: save the user info
        collection = db.user
        try:  # check if the userinfo is already there.
            selectall = collection.find_one({"uid": userdata["uid"]})
            # then we update,
            for key, value in userdata.items():
                if not (value == selectall[key]):
                    collection.update({key: value}, {key: userdata[key]})
            oid = selectall["_id"]
        except:  # if not there, then add new user info
            emptyjson = {}
            for key, value in userdata.items():
                emptyjson[key] = value
                # emptyjson["oauth_token"]=access_token.key
                # emptyjson["oauth_secret"]=access_token.secret
                emptyjson["files"] = []
            oid = collection.insert(emptyjson)

            # 3: get the metadata.
        folder_metadata = allowed_client.metadata("/")
        print "starting downloading...."
        downloader.start(folder_metadata, allowed_client, userdata, oid)
Beispiel #2
0
def download_hls_stream(master_playlist_uri, id='.', num_workers=10, refreash_interval=0, num_refreshes=1):
    '''
    Download hls stream to local folder indiciated by id
    @param master_playlist_uri
    @param id Defaut CWD
    @param num_workers Number of downloader workers
    @param refresh_interval unit: second, Default 0
    @param num_refreshes Default 1
    '''
    print('master_playlist_uri: {master_playlist_uri}'.format(master_playlist_uri=master_playlist_uri))
    local_root = id

    print('downloading {uri} to {local}'.format(uri=master_playlist_uri, local=local_root))
    old_cwd = util.chdir(local_root)

    downloader.start(num_workers)

    for r in range(0, num_refreshes):
        master_playlist = download_master_playlist(master_playlist_uri)

        if master_playlist.is_variant:
            host_root, subpath, master_playlist_file = util.parse_uri(master_playlist_uri)
            # download resource from stream playlist
            for playlist in master_playlist.playlists:
                if util.is_full_uri(playlist.uri):
                    download_stream(playlist.uri)
                    pass
                else:
                    playlist_uri = host_root + '/' + subpath + '/' + playlist.uri
                    download_stream(playlist_uri, os.path.dirname(playlist.uri))

            # download resource from media
            for m in master_playlist.media:
                if not m.uri:
                    continue
                if util.is_full_uri(m.uri):
                    download_stream(m.uri)
                    pass
                else:
                    media_uri = host_root + '/' + subpath + '/' + m.uri
                    download_stream(media_uri, os.path.dirname(m.uri))
        else:
            download_stream(master_playlist_uri)

        if refreash_interval:
            print('Refreshing the master playlist in {interval} seconds'.format(interval=refreash_interval))

        time.sleep(refreash_interval)

    downloader.join()
    downloader.stop()
    os.chdir(old_cwd)
Beispiel #3
0
def download(links, name):
    set_no_proxy()
    for link in links:
        try:
            print(f"Downloading from: {link}")
            informator.info(f"Pobieranie {name}")
            dl = downloader.start(link, name, 8)
            return  #kończe pętle, bo pobrałem
        except Exception:
            print(traceback.format_exc())
            print("Something went wrong :( I'll try again...")
            informator.warning("Coś poszło nie tak... Próbuję jeszcze raz...")
            continue
    #jeśli doszło do tego momentu to żaden z linków nie zadziałał, najprawdopodobniej z powodu braku internetu
    raise Exception('Żaden z linków nie zadziałał (down2/download)')
Beispiel #4
0
def run():
    pil.initialize()
    logging.disable(logging.CRITICAL)
    config = configparser.ConfigParser()
    parser = argparse.ArgumentParser(
        description="You are running PyInstaLive {:s} using Python {:s}".format(Constants.SCRIPT_VER,
                                                                                Constants.PYTHON_VER))

    parser.add_argument('-u', '--username', dest='username', type=str, required=False,
                        help="Instagram username to login with.")
    parser.add_argument('-p', '--password', dest='password', type=str, required=False,
                        help="Instagram password to login with.")
    parser.add_argument('-d', '--download', dest='download', type=str, required=False,
                        help="The username of the user whose livestream or replay you want to save.")
    parser.add_argument('-b,', '--batch-file', dest='batchfile', type=str, required=False,
                        help="Read a text file of usernames to download livestreams or replays from.")
    parser.add_argument('-i', '--info', dest='info', action='store_true', help="View information about PyInstaLive.")
    parser.add_argument('-nr', '--no-replays', dest='noreplays', action='store_true',
                        help="When used, do not check for any available replays.")
    parser.add_argument('-nl', '--no-lives', dest='nolives', action='store_true',
                        help="When used, do not check for any available livestreams.")
    parser.add_argument('-cl', '--clean', dest='clean', action='store_true',
                        help="PyInstaLive will clean the current download folder of all leftover files.")
    parser.add_argument('-cp', '--config-path', dest='configpath', type=str, required=False,
                        help="Path to a PyInstaLive configuration file.")
    parser.add_argument('-dp', '--download-path', dest='dlpath', type=str, required=False,
                        help="Path to folder where PyInstaLive should save livestreams and replays.")
    parser.add_argument('-as', '--assemble', dest='assemble', type=str, required=False,
                        help="Path to json file required by the assembler to generate a video file from the segments.")
    parser.add_argument('-df', '--download-following', dest='downloadfollowing', action='store_true',
                        help="PyInstaLive will check for available livestreams and replays from users the account "
                             "used to login follows.")
    parser.add_argument('-nhb', '--no-heartbeat', dest='noheartbeat', action='store_true', help="Disable heartbeat "
                                                                                                "check for "
                                                                                                "livestreams.")
    parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help="PyInstaLive will output JSON "
                                                                                     "responses and some misc "
                                                                                     "variables.")
    parser.add_argument('-sm', '--skip-merge', dest='skip_merge', action='store_true', help="PyInstaLive will not merge the downloaded livestream files.")
    parser.add_argument('-o', '--organize', action='store_true', help="Create a folder for each user whose livestream(s) you have downloaded. The names of the folders will be their usernames. Then move the video(s) of each user into their associated folder.")

    # Workaround to 'disable' argument abbreviations
    parser.add_argument('--usernamx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--passworx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--infx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--noreplayx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--cleax', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--downloadfollowinx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--configpatx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--confix', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('--organizx', help=argparse.SUPPRESS, metavar='IGNORE')

    parser.add_argument('-cx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('-nx', help=argparse.SUPPRESS, metavar='IGNORE')
    parser.add_argument('-dx', help=argparse.SUPPRESS, metavar='IGNORE')

    args, unknown_args = parser.parse_known_args()  # Parse arguments

    if validate_inputs(config, args, unknown_args):
        if not args.username and not args.password:
            pil.ig_api = auth.authenticate(username=pil.ig_user, password=pil.ig_pass)
        elif (args.username and not args.password) or (args.password and not args.username):
            logger.warn("Missing --username or --password argument. Falling back to config file.")
            logger.separator()
            pil.ig_api = auth.authenticate(username=pil.ig_user, password=pil.ig_pass)
        elif args.username and args.password:
            pil.ig_api = auth.authenticate(username=args.username, password=args.password, force_use_login_args=True)

        if pil.ig_api:
            if pil.dl_user or pil.args.downloadfollowing:
                downloader.start()
            elif pil.dl_batchusers:
                if not helpers.command_exists("pyinstalive"):
                    logger.error("PyInstaLive must be properly installed when using the -b argument.")
                    logger.separator()
                else:
                    dlfuncs.iterate_users(pil.dl_batchusers)
        'withLink': True
    }
    # Insert a file
    file = drive_service.files().insert(body=body,
                                        media_body=media_body).execute()
    # Insert new permissions
    drive_service.permissions().insert(fileId=file['id'],
                                       body=permissions).execute()
    # Define file instance and get url for download
    file = drive_service.files().get(fileId=file['id']).execute()
    download_url = file.get('webContentLink')
    return download_url


if __name__ == '__main__':
    file_path = downloader.start()
    try:
        with open(file_path) as f:
            pass
    except IOError as e:
        print(e)
        sys.exit(1)
# Check if token file exists, if not create it by requesting authorization code
    try:
        with open(token_file) as f:
            pass
    except IOError:
        http = authorize(token_file, create_token_file(token_file))
# Authorize, get file parameters, upload file and print out result URL for download
    http = authorize(token_file, None)
    file_name, mime_type = file_ops(file_path)
def main():
    import downloader
    downloader.start(init)
Beispiel #7
0
import os
import downloader

# dota2 = downloader.DownloadTask('http://dota2.dl.wanmei.com/dota2/client/DOTA2Setup20180206.zip','.',5)
downloader = downloader.Downloader()

downloader.setThreadNum(5)
# downloader.createTask('http://dota2.dl.wanmei.com/dota2/client/DOTA2Setup20180206.zip')
downloader.createTask('http://mxd.clientdown.sdo.com/150/Data150.zip')
downloader.createTask('http://mxd.clientdown.sdo.com/150/Data15001.cab')
downloader.createTask('http://mxd.clientdown.sdo.com/150/Data15002.cab')
downloader.createTask('http://mxd.clientdown.sdo.com/150/Maplestory150.exe')
downloader.start(0)
downloader.start(1)
downloader.start(2)
downloader.start(3)