« get me outta code hell

index.js - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/index.js
blob: b85e0e8a8f903a709a42fcb31c276915848f0658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// omg I am tired of code

const { getPlayer } = require('./players')
const { getDownloaderFor } = require('./downloaders')
const EventEmitter = require('events')

class InternalApp extends EventEmitter {
  constructor() {
    super()
    this.player = null
  }

  async setup() {
    this.player = await getPlayer()
  }

  async startPlaying(arg) {
    this.player.playFile(await this.download(arg))
  }

  download(arg) {
    return getDownloaderFor(arg)(arg)
  }
}

async function main() {
  const internalApp = new InternalApp()
  await internalApp.setup()
  internalApp.startPlaying('http://billwurtz.com/cable-television.mp3')
}

main().catch(err => console.error(err))