Ejemplo n.º 1
0
    def post(self):
        parser = reqparse.RequestParser()

        # These are the required parameters
        parser.add_argument('title', type=str, required=True, location='json')
        parser.add_argument('labels', type=list, required=True,
                            location='json')
        parser.add_argument('artists', type=list, required=True,
                            location='json')
        parser.add_argument('isrc', type=str, required=False,
                            location='json')
        parser.add_argument('X-OMI-PUBLIC-KEY', type=str, required=True,
                            location='headers')
        parser.add_argument('X-OMI-PRIVATE-KEY', type=str, required=True,
                            location='headers')
        args = parser.parse_args()

        manifestation = transform(args, 'Recording->CreativeWork')
        copyright_holder = {
            "public_key": args['X-OMI-PUBLIC-KEY'],
            "private_key": args['X-OMI-PRIVATE-KEY']
        }

        _, manifestation, _= coalaip.register_manifestation(
            manifestation_data=manifestation,
            copyright_holder=copyright_holder,
            work_data=None,
            create_work=False,
            create_copyright=False
        )

        print('Manifestation/Recording registered under: ',
              manifestation.persist_id)
        return 'The recording was successfully registered.', 200
Ejemplo n.º 2
0
 def get(self):
     args = queryparams_to_dict(request.args)
     res = bdb_find(query=args, _type='CreativeWork')
     resp = []
     for doc in res:
         doc = doc['block']['transactions']['asset']['data']
         doc = transform(doc, 'CreativeWork->Recording')
         resp.append(doc)
     return resp
Ejemplo n.º 3
0
    def post(self):
        parser = reqparse.RequestParser()

        # These are the required parameters
        parser.add_argument('title', type=str, required=True, location='json')
        parser.add_argument('composers',
                            type=list,
                            required=True,
                            location='json')
        parser.add_argument('songwriters',
                            type=list,
                            required=True,
                            location='json')
        parser.add_argument('publishers',
                            type=list,
                            required=True,
                            location='json')
        parser.add_argument('iswc', type=str, required=False, location='json')
        parser.add_argument('X-OMI-PUBLIC-KEY',
                            type=str,
                            required=True,
                            location='headers')
        parser.add_argument('X-OMI-PRIVATE-KEY',
                            type=str,
                            required=True,
                            location='headers')
        args = parser.parse_args()

        work = transform(args, 'Composition->AbstractWork')
        copyright_holder = {
            "public_key": args['X-OMI-PUBLIC-KEY'],
            "private_key": args['X-OMI-PRIVATE-KEY']
        }

        work = coalaip.register_work(work_data=work,
                                     copyright_holder=copyright_holder)

        print('Work/Composition registered under: ', work.persist_id)

        return 'The composition was successfully registered.', 200
Ejemplo n.º 4
0
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('isrc', type=str)
        parser.add_argument('iswc', type=str)

        args = queryparams_to_dict(request.args)
        results = []

        # First we need to look for all the recordings connected
        # to the composition (or the other way around, depending
        # on the user's query)
        match = map(unpack, bdb_find(query=args, _type='LinkToWork'))

        # If the user searched by `isrc` (aka recording)
        # then we need to return all the linked compositions.
        if 'isrc' in args:
            queries = [{'iswc': x['iswc']} for x in match]
            transformation = 'AbstractWork->Composition'
            _type = 'AbstractWork'
            key = 'composition'
        # otherwise we return the linked recordings.
        else:
            queries = [{'isrc': x['isrc']} for x in match]
            transformation = 'CreativeWork->Recording'
            _type = 'CreativeWork'
            key = 'recording'

        for query in queries:
            for result in bdb_find(query=query, _type=_type):
                result = transform(unpack(result), transformation)
                results.append({key: result})

        return {
            'count': len(results),
            'total': len(results),
            'offset': 0,
            'results': results
        }