Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # usage: ./example.py /path/to/file1 /path/to/file2 ...
  4. import shout
  5. import sys
  6. import string
  7. import time
  8.  
  9. s = shout.Shout()
  10. print "Using libshout version %s" % shout.version()
  11.  
  12. # s.host = 'localhost'
  13. # s.port = 8000
  14. # s.user = 'source'
  15. s.password = 'hackme'
  16. s.mount = "/pyshout"
  17. # s.format = 'vorbis' | 'mp3'
  18. # s.protocol = 'http' | 'xaudiocast' | 'icy'
  19. # s.name = ''
  20. # s.genre = ''
  21. # s.url = ''
  22. # s.public = 0 | 1
  23. # s.audio_info = { 'key': 'val', ... }
  24. # (keys are shout.SHOUT_AI_BITRATE, shout.SHOUT_AI_SAMPLERATE,
  25. # shout.SHOUT_AI_CHANNELS, shout.SHOUT_AI_QUALITY)
  26.  
  27. s.open()
  28.  
  29. total = 0
  30. st = time.time()
  31. for fa in sys.argv[1:]:
  32. print "opening file %s" % fa
  33. f = open(fa)
  34. s.set_metadata({'song': fa})
  35.  
  36. nbuf = f.read(4096)
  37. while 1:
  38. buf = nbuf
  39. nbuf = f.read(4096)
  40. total = total + len(buf)
  41. if len(buf) == 0:
  42. break
  43. s.send(buf)
  44. s.sync()
  45. f.close()
  46.  
  47. et = time.time()
  48. br = total*0.008/(et-st)
  49. print "Sent %d bytes in %d seconds (%f kbps)" % (total, et-st, br)
  50.  
  51. print s.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement