zipEXE.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. #
  3. #Copyright (C) 2017 avideo authors (see AUTHORS)
  4. #
  5. # This file is part of AVideo.
  6. #
  7. # AVideo is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # AVideo is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with AVideo. If not, see <http://www.gnu.org/licenses/>.
  19. zip 2&> /dev/null
  20. if [ $? == 127 ]; then
  21. #The zip command isn't available; default to a Python re-implementation of the task to be performed
  22. python -c "`cat $0 | tail -15`"
  23. else
  24. zip --quiet youtube-dl youtube_dl/*.py youtube_dl/*/*.py
  25. zip --quiet --junk-paths youtube-dl youtube_dl/__main__.py
  26. fi
  27. exit
  28. #A python re-implementation of the 'zips'
  29. import os, zipfile
  30. with zipfile.ZipFile('youtube-dl.zip', mode='w', compression=zipfile.ZIP_DEFLATED) as exezip:
  31. for pkgel in os.listdir('youtube_dl'):
  32. path = 'youtube_dl/'+pkgel
  33. if os.path.isfile(path):
  34. exezip.write(path)
  35. else:
  36. for pkgfile in os.listdir(path):
  37. exezip.write(path+'/'+pkgfile)
  38. exezip.write('youtube_dl/__main__.py', arcname='__main__.py')\