<commit_before>var rusha = new (require('rusha'))()
var metadataReader = require('music-metadata')
var fs = require('file-system')(['audio/mp3', 'audio/wav', 'audio/ogg'])
var coversActions = require('./covers.js')

var actions = {

  // Add a file as a song. This hashes the file, adds it to the filesystem,
  // gets the metadata and the duration and dispatches the result metadata.
  // To add multiple files just dispatch this action multiple times.
  ADD_SONG: (file) => {
    return (dispatch, getState) => {
      // Extract the file ending
      var file_ending = file.name.replace(/^.*(\.[A-Za-z0-9]{3})$/, '$1')

      // Read the file as an data url
      var reader = new window.FileReader()
      reader.readAsDataURL(file)
      reader.onloadend = function () {
        // Hash the file contents and set the filename based on that
        var hash = rusha.digestFromString(this.result)
        var hashName = hash + file_ending

        // Get the metadata off the file
        metadataReader(file, meta => {
          // Add the song to the file system
          fs.add({filename: hashName, file: file}, (err) => {
            if (err) throw new Error('Error adding file: ' + err)

            // Read the file as an url from the filesystem
            fs.get(hashName, (err, url) => {
              if (err) throw new Error('Error getting file: ' + err)

              // Create an audio element to check on the duration
              var audio = document.createElement('audio')
              audio.src = url
              audio.addEventListener('loadedmetadata', () => {
                var duration = audio.duration

                // Dispatch an action to update the view and save
                // the song data in local storage
                var song = {
                  id: hash,
                  filename: url,<commit_msg>Allow for empty file types (android...)<commit_after>var rusha = new (require('rusha'))()
var metadataReader = require('music-metadata')
var fs = require('file-system')(['', 'audio/mp3', 'audio/wav', 'audio/ogg'])
var coversActions = require('./covers.js')

var actions = {

  // Add a file as a song. This hashes the file, adds it to the filesystem,
  // gets the metadata and the duration and dispatches the result metadata.
  // To add multiple files just dispatch this action multiple times.
  ADD_SONG: (file) => {
    return (dispatch, getState) => {
      // Extract the file ending
      var file_ending = 'mp3'

      if (file.name.match(/^.*(\.[A-Za-z0-9]{3})$/)) {
        file_ending = file.name.replace(/^.*(\.[A-Za-z0-9]{3})$/, '$1')
      }

      // Read the file as an data url
      var reader = new window.FileReader()
      reader.readAsDataURL(file)
      reader.onloadend = function () {
        // Hash the file contents and set the filename based on that
        var hash = rusha.digestFromString(this.result)
        var hashName = hash + file_ending

        // Get the metadata off the file
        metadataReader(file, meta => {
          // Add the song to the file system
          fs.add({filename: hashName, file: file}, (err) => {
            if (err) throw new Error('Error adding file: ' + err)

            // Read the file as an url from the filesystem
            fs.get(hashName, (err, url) => {
              if (err) throw new Error('Error getting file: ' + err)

              // Create an audio element to check on the duration
              var audio = document.createElement('audio')
              audio.src = url
              audio.addEventListener('loadedmetadata', () => {
                var duration = audio.duration

                // Dispatch an action to update the view and save
                // the song data in local storage
                var song = {
                  id: hash,
                  filename: url,
{'fraction_non_alphanumeric': 0.11604809200209096, 'fraction_numerical': 0.0036591740721380033, 'mean_word_length': 2.022906793048973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5354306', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1006, 'n_words': 379}