collapses playlist into flat list containing the first source url for each track
177629
function getSourceList(playlist) {
  return (playlist || []).map((_, i) => getTrackSources(playlist, i)[0].src);
}
1152338
function collapseEasingObject (easingObject, tokenData) {
      Tweenable.each(tokenData, function (prop) {
        var currentProp = tokenData[prop];
        var chunkNames = currentProp.chunkNames;
        var chunkLength = chunkNames.length;
        var composedEasingString = '';

        for (var i = 0; i < chunkLength; i++) {
          composedEasingString += ' ' + easingObject[chunkNames[i]];
          delete easingObject[chunkNames[i]];
        }

        easingObject[prop] = composedEasingString.substr(1);
      });
    }
757455
def playlists(self):
        
        if self._playlists is None:
            playlists_data = self._api.user_playlists(self.identifier)
            playlists = []
            for playlist_data in playlists_data:
                playlist = _deserialize(playlist_data, PlaylistSchema)
                playlists.append(playlist)
            self._playlists = playlists
        return self._playlists
1166212
def get_track_scrobbles(self, artist, track, cacheable=False):
        

        params = self._get_params()
        params["artist"] = artist
        params["track"] = track

        seq = []
        for track in _collect_nodes(
            None, self, self.ws_prefix + ".getTrackScrobbles", cacheable, params
        ):
            title = _extract(track, "name")
            artist = _extract(track, "artist")
            date = _extract(track, "date")
            album = _extract(track, "album")
            timestamp = track.getElementsByTagName("date")[0].getAttribute("uts")

            seq.append(
                PlayedTrack(Track(artist, title, self.network), album, date, timestamp)
            )

        return seq
125034
def process_musicbed(vargs):
    

    # let's validate given MusicBed url
    validated = False
    if vargs['artist_url'].startswith( 'https://www.musicbed.com/' ):
        splitted = vargs['artist_url'][len('https://www.musicbed.com/'):].split( '/' )
        if len( splitted ) == 3:
            if ( splitted[0] == 'artists' or splitted[0] == 'albums' or splitted[0] == 'songs' ) and splitted[2].isdigit():
                validated = True

    if not validated:
        puts( colored.red( 'process_musicbed: you provided incorrect MusicBed url. Aborting.' ) )
        puts( colored.white( 'Please make sure that url is either artist-url, album-url or song-url.' ) )
        puts( colored.white( 'Example of correct artist-url: https://www.musicbed.com/artists/lights-motion/5188' ) )
        puts( colored.white( 'Example of correct album-url:  https://www.musicbed.com/albums/be-still/2828' ) )
        puts( colored.white( 'Example of correct song-url:   https://www.musicbed.com/songs/be-still/24540' ) )
        return

    filenames = scrape_musicbed_url(vargs['artist_url'], vargs['login'], vargs['password'], num_tracks=vargs['num_tracks'], folders=vargs['folders'], custom_path=vargs['path'])

    if vargs['open']:
        open_files(filenames)
701745
def createPlaylist(self, title, items=None, section=None, limit=None, smart=None, **kwargs):
        
        return Playlist.create(self, title, items=items, limit=limit, section=section, smart=smart, **kwargs)
740000
def listtracks(continuation_token: nil)
      oauth2_refresh_access_token if oauth2_access_token_expired?

      pb_body = MusicManager::ExportTracksRequest.new
      pb_body.client_id = uploader_id
      pb_body.export_type = MusicManager::ExportTracksRequest::TrackType::ALL
      pb_body.continuation_token = continuation_token unless continuation_token.nil?

      uri = URI('https://music.google.com/music/exportids')

      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true

      req = Net::HTTP::Post.new(uri.path)
      req.body = pb_body.serialize_to_string
      req['Content-Type'] = 'application/x-google-protobuf'
      req['Authorization'] = oauth2_authentication_header
      req['X-Device-ID'] = uploader_id
      res = http.request(req)

      unless res.is_a? Net::HTTPSuccess
        fail Error, 'listtracks failed: #{res.code}'
      end

      MusicManager::ExportTracksResponse.new.parse_from_string(res.body)
    end
339084
public SoundCloudTrack remove(int trackIndex) {

        SoundCloudTrack removedTrack = null;
        ArrayList<SoundCloudTrack> tracks = mSoundCloudPlaylist.getTracks();

        // check if track is in the playlist
        if (trackIndex >= 0 && trackIndex < tracks.size()) {
            removedTrack = tracks.remove(trackIndex);

            if (tracks.size() == 0) {
                // track list empty after removal
                mCurrentTrackIndex = 0;
            } else if (trackIndex == tracks.size()) {
                // last song removed
                mCurrentTrackIndex = (mCurrentTrackIndex - 1) % tracks.size();
            } else if (trackIndex >= 0 && trackIndex < mCurrentTrackIndex) {
                // tracks translated on the right after a deletion before current played one.
                mCurrentTrackIndex = (mCurrentTrackIndex - 1) % tracks.size();
            }
        }
        return removedTrack;
    }
43832
function(direction) {
    var self = this;

    // Get the next track based on the direction of the track.
    var index = 0;
    if (direction === 'prev') {
      index = self.index - 1;
      if (index < 0) {
        index = self.playlist.length - 1;
      }
    } else {
      index = self.index + 1;
      if (index >= self.playlist.length) {
        index = 0;
      }
    }

    self.skipTo(index);
  }
82948
def main():
    '''
    
    '''

    system('clear') # Must be system('cls') for windows

    setup()

    parser = argparse.ArgumentParser(
        description='Download songs with album art and metadata!')
    parser.add_argument('-c', '--config', action='store_true',
                        help='Set your API keys')
    parser.add_argument('-m', '--multiple', action='store', dest='multiple_file',
                        help='Download multiple songs from a text file list')
    parser.add_argument('-a', '--auto', action='store_true',
                        help='Automatically chooses top result')
    parser.add_argument('--album', action='store_true',
                        help='Downloads all songs from an album')
    args = parser.parse_args()
    arg_multiple = args.multiple_file or None
    arg_auto = args.auto or None
    arg_album = args.album or None
    arg_config = args.config


    if arg_config:
        add_config()

    elif arg_multiple and arg_album:
        log.log_error("Can't do both!")

    elif arg_album:
        album_name = input('Enter album name : ')
        try:
            tracks = get_tracks_from_album(album_name)
            for songs in tracks:
                print(songs)
            confirm = input(
                '\nAre these the songs you want to download? (Y/n)\n> ')

        except IndexError:
            log.log_error("Couldn't find album")
            exit()

        if confirm == '' or confirm.lower() == ('y'):
            for track_name in tracks:
                track_name = track_name + ' song'
                song_url, file_name = get_url(track_name, arg_auto)
                download_song(song_url, file_name)
                system('clear')
                repair.fix_music(file_name + '.mp3')

        elif confirm.lower() == 'n':
            log.log_error("Sorry, if appropriate results weren't found")
            exit()
        else:
            log.log_error('Invalid Input')
            exit()

    elif arg_multiple:
        with open(arg_multiple, "r") as f:
            file_names = []
            for line in f:
                file_names.append(line.rstrip('\n'))

        for files in file_names:
            files = files + ' song'
            song_url, file_name = get_url(files, arg_auto)
            download_song(song_url, file_name)
            system('clear')
            repair.fix_music(file_name + '.mp3')

    else:
        query = input('Enter Song Name : ')
        song_url, file_name = get_url(query, arg_auto)  # Gets YT url
        download_song(song_url, file_name)  # Saves as .mp3 file
        system('clear')
        repair.fix_music(file_name + '.mp3')
333702
def load_songs
      @songs = []
      playlist = @client.request('getPlaylistByID', playlistID: @id)
      @songs = playlist['songs'].map! do |s|
        Song.new(s)
      end if playlist.key?('songs')
      @songs
    end
277092
def playlists(self, *, include_songs=False):
		

		playlist_list = []
		for chunk in self.playlists_iter(page_size=49995):
			for playlist in chunk:
				if include_songs:
					playlist['tracks'] = self.playlist_songs(playlist)

				playlist_list.append(playlist)

		return playlist_list
675782
def fix_music(file_name):
    '''
    
    '''

    setup()

    if not Py3:
        file_name = file_name.encode('utf-8')

    tags = File(file_name)

    log.log(file_name)
    log.log('> Adding metadata')

    try:
        artist, album, song_name, lyrics, match_bool, score = get_details_spotify(
            file_name)  # Try finding details through spotify

    except Exception:
        artist, album, song_name, lyrics, match_bool, score = get_details_letssingit(
            file_name)  # Use bad scraping method as last resort

    try:
        log.log_indented('* Trying to extract album art from Google.com')
        albumart = albumsearch.img_search_google(artist+' '+album)
    except Exception:
        log.log_indented('* Trying to extract album art from Bing.com')
        albumart = albumsearch.img_search_bing(artist+' '+album)

    if match_bool:
        add_albumart(albumart, file_name)
        add_details(file_name, song_name, artist, album, lyrics)

        try:
            rename(file_name, artist+' - '+song_name+'.mp3')
        except Exception:
            log.log_error("Couldn't rename file")
            pass
    else:
        log.log_error(
            "* Couldn't find appropriate details of your song", indented=True)

    log.log("Match score: %s/10.0" % round(score * 10, 1))
    log.log(LOG_LINE_SEPERATOR)
    log.log_success()
873372
def getPlaylists(extras=nil)
      method = 'getPlaylists'
      type = Playlist
      args = {}
      args[:extras] = extras if extras
      return_object type,method,args,true
    end
569615
function(parts) {
        var urls = [];
        var start = '';

        // If the first part is empty
        // the original path begins with a slash so we
        // do that, too

        if( _.isEmpty(parts[0]) ) {
            start = '/';
            urls[0] = '/';      // would not be generated in reduce()
        }

        _.reduce(parts, function(acc, value){

            if( ! _.isString(value) || _.isEmpty(value) )
                return acc;

            acc += value;

            // Push w/out trailing slash
            urls.push(acc);

            return acc + '/';
        }, start );

        return urls;
    }
979627
def songs_delete(self, songs):
		

		mutations = [mc_calls.TrackBatch.delete(song['id']) for song in songs]
		response = self._call(
			mc_calls.TrackBatch,
			mutations
		)

		success_ids = [
			res['id']
			for res in response.body['mutate_response']
			if res['response_code'] == 'OK'
		]

		# TODO: Report failures.
		# failure_ids = [
		# 	res['id']
		# 	for res in response.body['mutate_response']
		# 	if res['response_code'] != 'OK'
		# ]

		return success_ids
1215733
def addToPlaylist(playlist,tracks)
      method = 'addToPlaylist'
      type = true
      args = {:playlist=>playlist, :tracks=>Rdio::keys(tracks)}
      return_object type,method,args,true
    end