<commit_before>import Track from './Track';

export default class Playlist {
  static fromPlaylistObject = (id, playlistObject) => {
    const playlist = new Playlist(id, playlistObject.Oh.replace(/ playlist$/g, ''));
    playlist.addTracks(playlistObject.items.map((track) => Track.fromTrackArray(track.Pf.Lc, track.index)));
    return playlist;
  };

  constructor(id, name) {
    this.id = id;
    this.name = name;
    this.tracks = [];
  }

  addTracks(tracks) {
    this.tracks = this.tracks.concat(tracks);
    this._sort();
  }

  addTrack(track) {
    this.tracks.push(track);
    this._sort();
  }
<commit_msg>Search for track path aswell<commit_after>import Track from './Track';

let songArrayPath;

export default class Playlist {
  static fromPlaylistObject = (id, playlistObject) => {
    const playlist = new Playlist(id, playlistObject.getTitle().replace(/ playlist$/g, ''));
    if (playlistObject.items.length > 0 && !songArrayPath) {
      Object.keys(playlistObject.items[0]).forEach((trackKey) => {
        if (typeof playlistObject.items[0][trackKey] === 'object') {
          Object.keys(playlistObject.items[0][trackKey]).forEach((trackArrKey) => {
            if (Array.isArray(playlistObject.items[0][trackKey][trackArrKey])) {
              songArrayPath = [trackKey, trackArrKey];
            }
          });
        }
      });
    }
    if (!songArrayPath) return playlist;
    playlist.addTracks(playlistObject.items.map((track) => Track.fromTrackArray(track.Pf.Lc, track.index)));
    return playlist;
  };

  constructor(id, name) {
    this.id = id;
    this.name = name;
    this.tracks = [];
  }

  addTracks(tracks) {
    this.tracks = this.tracks.concat(tracks);
    this._sort();
  }

  addTrack(track) {
    this.tracks.push(track);
    this._sort();
  }

{'fraction_non_alphanumeric': 0.1547022815804118, 'fraction_numerical': 0.0027824151363383415, 'mean_word_length': 3.181395348837209, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6779655', 'n_tokens_mistral': 605, 'n_tokens_neox': 580, 'n_words': 99}