Page MenuHomePhabricator

Come up with a single-call API mechanism to fetch the captions (and other structured data) of a given file
Open, Needs TriagePublic

Description

Right now, to pull the captions of a file, you need to do two things.

First, you map the titles to the mediainfo_entity values, via action=query&prop=pageprops&ppprop=mediainfo_entity which gives you something like:

{
    "query": {
        "pages": [
            {
                "pageid": 1,
                "ns": 6,
                "title": "File:Foo.jpg",
                "pageprops": {
                    "mediainfo_entity": "M1"
                }
            },
            {
                "pageid": 2,
                "ns": 6,
                "title": "File:Bar.jpg",
                "pageprops": {
                    "mediainfo_entity": "M2"
                }
            }
        ]
    }
}

… and then you use the extracted values as the feed-in for the query to get the captions via action=wbgetentities&props=labels&ids=M1%7CM2:

{
    "entities": {
        "M1": {
            "type": "mediainfo",
            "id": "M1",
            "labels": {
                "en": {
                    "language": "en",
                    "value": "Hello!"
                },
                "fr": {
                    "language": "fr",
                    "value": "Bonjour!"
                }
            },
            "statements": []
        },
        "M2": {
            "type": "mediainfo",
            "id": "M2",
            "labels": {
                "da": {
                    "language": "da",
                    "value": "hallo"
                },
                "is": {
                    "language": "is",
                    "value": "hæ"
                }
            },
            "statements": []
        }
    }
}

It might be nice to come up with a title-based generator for the wbentities query so that people would only have to do something like action=wbgetentities&props=labels&gwbmediainfo=File:Foo.jpg%7CFile:Bar.jpg

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 10 2018, 3:55 PM
Abbe98 added a subscriber: Abbe98.Jan 11 2019, 10:54 PM
greg added a project: Multimedia.Mar 7 2019, 10:59 PM
Ramsey-WMF moved this task from Untriaged to Desired epics on the Multimedia board.Mar 8 2019, 2:54 AM
Restricted Application added a project: Multimedia. · View Herald TranscriptAug 10 2019, 11:54 PM