librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1213] Add script to print time of most recent gobble.


From: Daniel Watkins
Subject: [Librefm-commits] [1213] Add script to print time of most recent gobble.
Date: Tue, 05 May 2009 23:58:36 +0000

Revision: 1213
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1213
Author:   odd_bloke
Date:     2009-05-05 23:58:36 +0000 (Tue, 05 May 2009)
Log Message:
-----------
Add script to print time of most recent gobble.

Added Paths:
-----------
    trunk/scripts/most_recent.py

Added: trunk/scripts/most_recent.py
===================================================================
--- trunk/scripts/most_recent.py                                (rev 0)
+++ trunk/scripts/most_recent.py        2009-05-05 23:58:36 UTC (rev 1213)
@@ -0,0 +1,22 @@
+from datetime import datetime
+from optparse import OptionParser
+from urllib2 import urlopen
+
+from BeautifulSoup import BeautifulSoup
+
+
+if __name__ == '__main__':
+    usage = "%prog <USERNAME> <WEB SERVER>"
+    parser = OptionParser(usage=usage)
+    opts,args = parser.parse_args()
+    if len(args) != 2:
+        parser.error("All arguments are required.")
+
+    username,server = args
+    if server[:7] != "http://":
+        server = "http://%s"; % (server,)
+    soup = BeautifulSoup(urlopen('%s/user/%s/recent-tracks'
+                                    % (server, username)))
+    gobbles_list = soup.find('ul', {'class': 'gobbles'})
+    timestamp = gobbles_list.find('li')['about'].split('#')[1].split('.')[0]
+    print datetime.fromtimestamp(float(timestamp))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]