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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
"""
Mediahub - Fetch screenshots and gameclips
"""
from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.mediahub.models import (
MediahubGameclips,
MediahubScreenshots,
)
class MediahubProvider(BaseProvider):
MEDIAHUB_URL = "https://mediahub.xboxlive.com"
HEADERS = {"x-xbl-contract-version": "3"}
async def fetch_own_clips(
self, skip: int = 0, count: int = 500, **kwargs
) -> MediahubGameclips:
"""
Fetch own clips
Args:
skip: Number of items to skip
count: Max entries to fetch
Returns:
:class:`MediahubGameclips`: Gameclips
"""
url = f"{self.MEDIAHUB_URL}/gameclips/search"
post_data = {
"max": count,
"query": f"OwnerXuid eq {self.client.xuid}",
"skip": skip,
}
resp = await self.client.session.post(
url, json=post_data, headers=self.HEADERS, **kwargs
)
resp.raise_for_status()
return MediahubGameclips(**resp.json())
async def fetch_own_screenshots(
self, skip: int = 0, count: int = 500, **kwargs
) -> MediahubScreenshots:
"""
Fetch own screenshots
Args:
skip: Number of items to skip
count: Max entries to fetch
Returns:
:class:`MediahubScreenshots`: Screenshots
"""
url = f"{self.MEDIAHUB_URL}/screenshots/search"
post_data = {
"max": count,
"query": f"OwnerXuid eq {self.client.xuid}",
"skip": skip,
}
resp = await self.client.session.post(
url, json=post_data, headers=self.HEADERS, **kwargs
)
resp.raise_for_status()
return MediahubScreenshots(**resp.json())
|