Example #1
0
def main():
    """
    Find Wikidata items that are missing a iTunes movie ID (P6398) but have a
    Apple TV movie ID (P9586).

    Outputs QuickStatements CSV commands.
    """

    qids = page_qids("User:Josh404Bot/Preliminarily matched/P6398")
    qids |= sample_items("P9586", limit=1000)

    allowed_classes = type_constraints("P6398")
    results = fetch_statements(qids, ["P31", "P6398", "P9586"])

    print("qid,P6398")
    for qid in tqdm(results):
        item = results[qid]

        if qid in blocked_qids():
            logging.debug("{} is blocked".format(qid))
            continue

        if not item.get("P31") or item.get("P6398"):
            continue

        instance_of = set([v for (_, v) in item["P31"]])
        if instance_of.isdisjoint(allowed_classes):
            continue

        for (statement, value) in item.get("P9586", []):
            movie = appletv.movie(value)
            if movie and movie["itunes_id"]:
                print('{},"""{}"""'.format(qid, movie["itunes_id"]))
Example #2
0
def test_fetch_statements():
    items = fetch_statements(["Q172241"], ["P345", "P4947"])
    assert len(items) == 1

    item = items["Q172241"]
    assert item
    assert item["P345"]
    assert item["P4947"]
Example #3
0
def main():
    assert not appletv.all_not_found(type="movie",
                                     id="umc.cmc.o5z5ztufuu3uv8lx7m0jcega")

    qids = sample_items("P9586", limit=250)
    qids |= page_qids("Wikidata:Database reports/Constraint violations/P9586")

    results = sparql.fetch_statements(qids, ["P9586"])

    for qid in results:
        item = results[qid]

        for (statement, value) in item.get("P9586", []):
            if not MATCHER.match(value):
                continue

            if appletv.all_not_found(type="movie", id=value):
                print("{},Q21441764".format(statement))
Example #4
0
def main():
    assert not appletv.all_not_found(type="episode",
                                     id="umc.cmc.1488ez4dp942etebq3p85k1np")

    qids = sample_items("P9750", limit=250)
    qids |= page_qids("Wikidata:Database reports/Constraint violations/P9750")

    results = sparql.fetch_statements(qids, ["P9750"])

    for qid in results:
        item = results[qid]

        for (statement, value) in item.get("P9750", []):
            if not MATCHER.match(value):
                continue

            if appletv.all_not_found(type="episode", id=value):
                print("{},Q21441764".format(statement))
Example #5
0
def main():
    assert not appletv.all_not_found(type="show",
                                     id="umc.cmc.vtoh0mn0xn7t3c643xqonfzy")

    qids = sample_items("P9751", limit=250)
    qids |= page_qids("Wikidata:Database reports/Constraint violations/P9751")

    results = sparql.fetch_statements(qids, ["P9751"])

    for qid in results:
        item = results[qid]

        for (statement, value) in item.get("P9751", []):
            if not MATCHER.match(value):
                continue

            if appletv.all_not_found(type="show", id=value):
                print("{},Q21441764".format(statement))
Example #6
0
def main():
    (id, obj) = next(itunes.batch_lookup([567661493]))
    assert id and obj

    qids = sample_items("P6398", limit=10000)
    qids |= page_qids("Wikidata:Database reports/Constraint violations/P6398")

    results = sparql.fetch_statements(qids, ["P6398"])

    itunes_ids = {}

    for qid in results:
        item = results[qid]

        for (statement, value) in item.get("P6398", []):
            try:
                id = int(value)
                itunes_ids[id] = statement
            except ValueError:
                continue

    for (id, obj) in itunes.batch_lookup(itunes_ids.keys()):
        if not obj and itunes.all_not_found(id):
            print("{},Q21441764".format(itunes_ids[id]))