[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1205] Added offline-submit script.
From: |
Daniel Watkins |
Subject: |
[Librefm-commits] [1205] Added offline-submit script. |
Date: |
Tue, 05 May 2009 21:47:33 +0000 |
Revision: 1205
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1205
Author: odd_bloke
Date: 2009-05-05 21:47:32 +0000 (Tue, 05 May 2009)
Log Message:
-----------
Added offline-submit script.
Added Paths:
-----------
trunk/scripts/offline-submit.py
Added: trunk/scripts/offline-submit.py
===================================================================
--- trunk/scripts/offline-submit.py (rev 0)
+++ trunk/scripts/offline-submit.py 2009-05-05 21:47:32 UTC (rev 1205)
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+import datetime
+import getpass
+from optparse import OptionParser
+import subprocess
+
+import mutagen
+from mutagen import easyid3
+
+from gobble import GobbleServer
+
+
+def _parse_date(string):
+ process = subprocess.Popen(['date', '-d %s' % (string,), '+%s'],
+ stdout=subprocess.PIPE)
+ string = process.communicate()[0].strip()
+ return datetime.datetime.utcfromtimestamp(float(string))
+
+
+if __name__ == '__main__':
+ usage = "%prog <USERNAME> <SERVER> <START TIME> <MEDIA FILES>"
+ parser = OptionParser(usage=usage)
+ opts,args = parser.parse_args()
+ if len(args) < 4:
+ parser.error("All arguments are required.")
+
+ username,server,start_string = args[:3]
+ password = getpass.getpass()
+ tracks = args[3:]
+ server = GobbleServer(server, username, password)
+
+ dt = _parse_date(start_string)
+
+ for track in tracks:
+ f = mutagen.File(track)
+ if f is None:
+ raise Exception("%s caused problems." % (track,))
+ if isinstance(f, mutagen.mp3.MP3):
+ f = mutagen.mp3.MP3(track, ID3=easyid3.EasyID3)
+ title = f['title'][0]
+ artist = f['artist'][0]
+ length = f.info.length
+ server.add_track(artist, title, dt)
+ dt += datetime.timedelta(seconds=length)
+ server.submit()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1205] Added offline-submit script.,
Daniel Watkins <=