Advertisement
Guest User

Untitled

a guest
May 27th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!/usr/bin/env python2
  2.  
  3. import json
  4. import socket
  5. import os.path
  6.  
  7. def get_mpv_info():
  8.     client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
  9.     client.connect("/tmp/mpvsocket")
  10.     for i in ['media-title', 'playback-time', 'length']:
  11.         req = '{"command": ["get_property", "%s"]}\n' %i
  12.         client.send(req)
  13.         res[i] = json.loads(client.recv(1024))['data']
  14.        
  15.     client.close()
  16.     return res
  17.    
  18. d = get_mpv_info()
  19. print(d['filename'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement