all repos — rastro @ 6533c8851b4a2970689b2081579d5f63f5136a58

BitTorrent tracker!

app/collectors/xiu2.py (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
"""XIU2/TrackersListCollection collector.

Daily aggregator of several upstream tracker lists (GPL-3.0). As with the
GPLv2 trackerslist feed, only published data is consumed -- no GPL code is
used. `all.txt` seeds endpoints; `best.txt` only sets the best-at-source flag.
"""

from __future__ import annotations

import httpx
from sqlalchemy.ext.asyncio import AsyncSession

from app.collectors.base import EnrichmentFeed, ImportStats, import_source_feeds
from app.config import Settings

SOURCE_NAME = "xiu2"


class Xiu2Collector:
    name = SOURCE_NAME

    async def import_once(
        self, session: AsyncSession, client: httpx.AsyncClient, settings: Settings
    ) -> ImportStats:
        return await import_source_feeds(
            session,
            client,
            source_name=SOURCE_NAME,
            primary_url=settings.xiu2_all_url,
            enrichments=[EnrichmentFeed(url=settings.xiu2_best_url, is_best=True)],
        )