0xDB: Add some annotations #402

Open
opened 2012-02-10 05:22:41 +00:00 by rlx · 1 comment
Owner

Sans Soleil, Histoire(s) du cinéma etc.

Sans Soleil, Histoire(s) du cinéma etc.
rlx added the
general
label 2012-02-10 05:22:41 +00:00
0x2620 was assigned by rlx 2012-02-10 05:22:41 +00:00
rlx added the
normal
task
labels 2012-02-10 05:22:41 +00:00
rlx added this to the 12.04 milestone 2012-07-01 08:34:02 +00:00
Author
Owner

Just imported the caption track from the Australian Edition of "Histoire(s) du cinéma": https://0xdb.org/0097514/editor

import os
import ox

# make sure encoding is utf-8 and newlines are lf

api = ox.API('https://0xdb.org/api/')
api.signin({'username': 'username', 'password': 'password'})

for filename in sorted(
    [filename for filename in os.listdir('.') if filename.endswith('.srt')]
):
    id = filename[:7]
    for annotation in sorted(
        api.get({'id': id, 'keys': ['layers']})['data']['layers']['publicnotes'],
        key=lambda annotation: annotation['id']
    ):
        print 'removing', annotation['id']
        api.removeAnnotation({'id': annotation['id']})
    for annotation in ox.srt.load(filename, offset=-21.56):
        print 'adding', api.addAnnotation({
            'item': id,
            'layer': 'publicnotes',
            'in': annotation['in'],
            'out': annotation['out'],
            'value': annotation['value'].replace('\n', '<br>')
        })['data']['id']
Just imported the caption track from the Australian Edition of "Histoire(s) du cinéma": <https://0xdb.org/0097514/editor> ``` import os import ox # make sure encoding is utf-8 and newlines are lf api = ox.API('https://0xdb.org/api/') api.signin({'username': 'username', 'password': 'password'}) for filename in sorted( [filename for filename in os.listdir('.') if filename.endswith('.srt')] ): id = filename[:7] for annotation in sorted( api.get({'id': id, 'keys': ['layers']})['data']['layers']['publicnotes'], key=lambda annotation: annotation['id'] ): print 'removing', annotation['id'] api.removeAnnotation({'id': annotation['id']}) for annotation in ox.srt.load(filename, offset=-21.56): print 'adding', api.addAnnotation({ 'item': id, 'layer': 'publicnotes', 'in': annotation['in'], 'out': annotation['out'], 'value': annotation['value'].replace('\n', '<br>') })['data']['id'] ```
rlx added this to the 13.04 milestone 2013-05-29 13:44:01 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: 0x2620/pandora#402
No description provided.