示例#1
0
 def build_ingest_dict(self, j):
     i = {
         "track_id": self.pk,
         "fp": fp.decode_code_string(j['code']),
         "codever": j['metadata']['version'],
         "length": self.media.duration
     }
     return i
 def write_codegen_file(self,j):
     fout = open(os.path.join(CODEGEN_DIR,self.codegen_fname),'w')
     fout.write(json.dumps(j))
     fout.close()
     self.sfm_client.add(1,
                         self.media.id,
                         fp.decode_code_string(j['code']),
                         title=self.media.ad.title)
示例#3
0
 def write_codegen_file(self, j):
     fout = open(os.path.join(CODEGEN_DIR, self.codegen_fname), 'w')
     fout.write(json.dumps(j))
     fout.close()
     self.sfm_client.add(1,
                         self.media.id,
                         fp.decode_code_string(j['code']),
                         title=self.media.ad.title)
示例#4
0
def lookup(fingerprint):
    if len(fingerprint):
        decoded = fp.decode_code_string(fingerprint)
        result = fp.best_match_for_query(decoded)
        if result.match():
            return result.TRID
        else:
            return False
    else:
        return False
示例#5
0
def lookup(fingerprint):
    if len(fingerprint):
        decoded = fp.decode_code_string(fingerprint)
        result = fp.best_match_for_query(decoded)
        if result.match():
            return result.TRID
        else:
            return False
    else:
        return False
示例#6
0
 def lookup(self,the_hash):
     #THIS WAS JUST FOR TESTING
     # return the_hash  
     if len(the_hash):
         decoded = fp.decode_code_string(the_hash)
         result = fp.best_match_for_query(decoded)
         if result.TRID:
             return result.TRID
         else:
             return 0
     else:
         return 0
示例#7
0
 def handle(self, *args, **options):
     w = os.walk(CODEGEN_DIR)
     d,dns,fns = w.next()
     for fn in fns:
         media_id = int(fn.split('_')[1])
         try:
             media_object = Media.objects.get(id=media_id)
         except Media.DoesNotExist:
             print '%s has no media object!'%(fn,)
             continue
         dd = eval(open(os.path.join(d,fn)).read())
         try:
             code_string = ' '.join(fp.decode_code_string(dd['code']).split()[::2])
         except KeyError:
             print '%s has no code!'%(fn,)
         res = eval(sfm_client.add(1,media_id,code_string,title=media_object.ad.title))
         if res['success']:
             continue
         else:
             print "problem ingesting Media object %d"%(media_id,)
 def build_ingest_dict(self,j):
     i = {   "track_id"  : self.pk,
             "fp"        : fp.decode_code_string(j['code']),
             "codever"   : j['metadata']['version'],
             "length"    : self.media.duration }
     return i