def __init__(self): #Mac and hostname are used to identify our client. self.mac = hex(getmac())[2:-1] self.mac = ':'.join([self.mac[x:x + 2] for x in range(0, 10, 2)]) hostname = gethostname() #Pre-filled protobuff instances. #These are used to fill in new instances. #Named scheme is '[protocol name]_filled' self.upload_auth_filled = metadata_pb2.UploadAuth() self.upload_auth_filled.address = self.mac self.upload_auth_filled.hostname = hostname self.client_state_filled = metadata_pb2.ClientState() self.client_state_filled.address = self.mac self.upload_auth_response_filled = metadata_pb2.UploadAuthResponse() self.client_state_response_filled = metadata_pb2.ClientStateResponse() self.metadata_request_filled = metadata_pb2.MetadataRequest() self.metadata_request_filled.address = self.mac self.metadata_response_filled = metadata_pb2.MetadataResponse() #Service name mapped to url. self.pb_services = { "upload_auth": 'upauth', "client_state": 'clientstate', "metadata": 'metadata?version=1' }
if options.verbose: print mac, hostname import metadata_pb2 uauth = metadata_pb2.UploadAuth() uauth.address = mac uauth.hostname = hostname uauthresp = metadata_pb2.UploadAuthResponse() uauthresp.ParseFromString(protopost("upauth", uauth)) if options.verbose: print uauthresp clientstate = metadata_pb2.ClientState() clientstate.address = mac clientstateresp = metadata_pb2.ClientStateResponse() clientstateresp.ParseFromString(protopost("clientstate", clientstate)) print clientstateresp.quota metadata = metadata_pb2.MetadataRequest() metadata.address = mac from mutagen.easyid3 import EasyID3 from mutagen.mp3 import MP3 import random import string import os filemap = {} #this maps a generated ClientID with a filename for filename in args: