def scrape_musicbed_url(url, login, password, num_tracks=sys.maxsize, folders=False, custom_path=''):
    """
    Scrapes provided MusicBed url.
    Uses requests' Session object in order to store cookies.
    Requires login and password information.
    If provided url is of pattern 'https://www.musicbed.com/artists/<string>/<number>' - a number of albums will be downloaded.
    If provided url is of pattern 'https://www.musicbed.com/albums/<string>/<number>'  - only one album will be downloaded.
    If provided url is of pattern 'https://www.musicbed.com/songs/<string>/<number>'   - will be treated as one album (but download only 1st track).
    Metadata and urls are obtained from JavaScript data that's treated as JSON data.

    Returns:
        list: filenames to open
    """

    session = requests.Session()

    response = session.get( url )
    if response.status_code != 200:
        puts( colored.red( 'scrape_musicbed_url: couldn\'t open provided url. Status code: ' + str( response.status_code ) + '. Aborting.' ) )
        session.close()
        return []

    albums = []
    # let's determine what url type we got
    # '/artists/' - search for and download many albums
    # '/albums/'  - means we're downloading 1 album
    # '/songs/'   - means 1 album as well, but we're forcing num_tracks=1 in order to download only first relevant track
    if url.startswith( 'https://www.musicbed.com/artists/' ):
        # a hackjob code to get a list of available albums
        main_index = 0
        while response.text.find( 'https://www.musicbed.com/albums/', main_index ) != -1:
            start_index = response.text.find( 'https://www.musicbed.com/albums/', main_index )
            end_index   = response.text.find( '">', start_index )
            albums.append( response.text[start_index:end_index] )
            main_index = end_index
    elif url.startswith( 'https://www.musicbed.com/songs/' ):
        albums.append( url )
        num_tracks = 1
    else: # url.startswith( 'https://www.musicbed.com/albums/' )
        albums.append( url )

    # let's get our token and try to login (csrf_token seems to be present on every page)
    token = response.text.split( 'var csrf_token = "' )[1].split( '";' )[0]
    details = { '_token': token, 'login': login, 'password': password }
    response = session.post( 'https://www.musicbed.com/ajax/login', data=details )
    if response.status_code != 200:
        puts( colored.red( 'scrape_musicbed_url: couldn\'t login. Aborting. ' ) + colored.white( 'Couldn\'t access login page.' ) )
        session.close()
        return []
    login_response_data = demjson.decode( response.text )
    if not login_response_data['body']['status']:
        puts( colored.red( 'scrape_musicbed_url: couldn\'t login. Aborting. ' ) + colored.white( 'Did you provide correct login and password?' ) )
        session.close()
        return []

    # now let's actually scrape collected pages
    filenames = []
    for each_album_url in albums:
        response = session.get( each_album_url )
        if response.status_code != 200:
            puts_safe( colored.red( 'scrape_musicbed_url: couldn\'t open url: ' + each_album_url +
                                    '. Status code: ' + str( response.status_code ) + '. Skipping.' ) )
            continue

        # actually not a JSON, but a JS object, but so far so good
        json = response.text.split( 'App.components.SongRows = ' )[1].split( '</script>' )[0]
        data = demjson.decode( json )

        song_count = 1
        for each_song in data['loadedSongs']:
            if song_count > num_tracks:
                break

            try:
                url, params = each_song['playback_url'].split( '?' )

                details = dict()
                for each_param in params.split( '&' ):
                    name, value = each_param.split( '=' )
                    details.update( { name: value } )
                # musicbed warns about it if it's not fixed
                details['X-Amz-Credential'] = details['X-Amz-Credential'].replace( '%2F', '/' )

                directory = custom_path
                if folders:
                    sanitized_artist = sanitize_filename( each_song['album']['data']['artist']['data']['name'] )
                    sanitized_album  = sanitize_filename( each_song['album']['data']['name'] )
                    directory = join( directory, sanitized_artist + ' - ' + sanitized_album )
                    if not exists( directory ):
                        mkdir( directory )
                filename = join( directory, str( song_count ) + ' - ' + sanitize_filename( each_song['name'] ) + '.mp3' )

                if exists( filename ):
                    puts_safe( colored.yellow( 'Skipping' ) + colored.white( ': ' + each_song['name'] + ' - it already exists!' ) )
                    song_count += 1
                    continue

                puts_safe( colored.green( 'Downloading' ) + colored.white( ': ' + each_song['name'] ) )
                path = download_file( url, filename, session=session, params=details )

                # example of genre_string:
                # "<a href=\"https://www.musicbed.com/genres/ambient/2\">Ambient</a> <a href=\"https://www.musicbed.com/genres/cinematic/4\">Cinematic</a>"
                genres = ''
                for each in each_song['genre_string'].split( '</a>' ):
                    if ( each != "" ):
                        genres += each.split( '">' )[1] + '/'
                genres = genres[:-1] # removing last '/

                tag_file(path,
                         each_song['album']['data']['artist']['data']['name'],
                         each_song['name'],
                         album=each_song['album']['data']['name'],
                         year=int( each_song['album']['data']['released_at'].split( '-' )[0] ),
                         genre=genres,
                         artwork_url=each_song['album']['data']['imageObject']['data']['paths']['original'],
                         track_number=str( song_count ),
                         url=each_song['song_url'])

                filenames.append( path )
                song_count += 1
            except:
                puts_safe( colored.red( 'Problem downloading ' ) + colored.white( each_song['name'] ) + '. Skipping.' )
                song_count += 1

    session.close()

    return filenames
Scrapes provided MusicBed url.
    Uses requests' Session object in order to store cookies.
    Requires login and password information.
    If provided url is of pattern 'https://www.musicbed.com/artists/<string>/<number>' - a number of albums will be downloaded.
    If provided url is of pattern 'https://www.musicbed.com/albums/<string>/<number>'  - only one album will be downloaded.
    If provided url is of pattern 'https://www.musicbed.com/songs/<string>/<number>'   - will be treated as one album (but download only 1st track).
    Metadata and urls are obtained from JavaScript data that's treated as JSON data.

    Returns:
        list: filenames to open