# Maintainer: André Silva <emulatorman@hyperbola.info>

pkgname=dontpanic
pkgver=2.0
pkgrel=1
pkgdesc="Dontpanic is a python app to look for any movie or serie and watch them in 'streaming'. It looks like popcorntime, but doesn't depend of a centralized api."
arch=(any)
url=http://3hg.toile-libre.org/dontpanic/index.html
license=(MIT)
depends=('python-bottle' 'python-requests' 'python-beautifulsoup4' 'sqlite' 'libtorrent-rasterbar')
optdepends=('python-cherrypy: for server mode')
makedepends=('git')
replaces=(popcorntime)
conflicts=(popcorntime)
provides=(popcorntime)
source=("$pkgname.tgz::http://3hg.toile-libre.org/dontpanic/downloads/dontpanic-latest.tgz")
sha256sums=('a79fc5d008cfc1f46da430ea56c19c39ab4128a8c93d95554b77b395dede54c3')

prepare() {
  cd  "${srcdir}/$pkgname"
  sed -i 's|python3.4|python|' $pkgname
  sed -i 's|python3|python|' $pkgname
  sed -i 's|torent|torrent|' $pkgname.desktop
}

package() {
  install -dm755 "$pkgdir/usr/bin"
  install -dm755 "$pkgdir/usr/share"
  install -dm755 "$pkgdir/usr/share/$pkgname/"
  install -dm755 "$pkgdir/usr/share/$pkgname/dontpanic/"
  install -dm755 "$pkgdir/usr/share/$pkgname/static/"
  install -dm755 "$pkgdir/usr/share/$pkgname/views/"
  install -dm755 "$pkgdir/usr/share/man/man1/"

  cd  "${srcdir}/$pkgname/src/"
  for _file in *.py; do
    install -D -m 644 $_file "$pkgdir/usr/share/$pkgname/"
  done

  cd  "${srcdir}/$pkgname/src/dontpanic/"
  for _file in *.py; do
    install -D -m 644 $_file "$pkgdir/usr/share/$pkgname/dontpanic/"
  done

  cd "${srcdir}/$pkgname/src/static/"
  for _file in *.png *.ico *.css; do
    install -D -m 644 $_file "$pkgdir/usr/share/$pkgname/static/"
  done

  cd "${srcdir}/$pkgname/src/views/"
  for _file in *.tpl; do
    install -D -m 644 $_file "$pkgdir/usr/share/$pkgname/views/"
  done

  install -D -m 755 "${srcdir}/$pkgname/dontpanic" "$pkgdir/usr/bin/dontpanic"
  install -Dm644 "${srcdir}/$pkgname/src/dontpanic.png" "$pkgdir/usr/share/pixmaps/dontpanic.png"
  install -Dm644 "${srcdir}/$pkgname/dontpanic.desktop" "$pkgdir/usr/share/applications/dontpanic.desktop"
  install -Dm644 "${srcdir}/$pkgname/dontpanic.1.gz" "$pkgdir/usr/share/man/man1/"
}


