popcorn-official / popcorn-api

Popcorn Time is a multi-platform, free software BitTorrent client that includes an integrated media player. Compatible API Anime/Movies/Show Scrapper
https://popcorntime.app
MIT License
622 stars 100 forks source link

Use JSON array instead objects only #51

Closed vzamanillo closed 7 years ago

vzamanillo commented 7 years ago

We are using objects only for responses with variable key names, this difficults the parsing process and the model definition (we are forced to use any getter or any setter annotations), an example for common torrents:

"torrents": {
    "en": {
        "1080p": {
            "url": "magnet:?xt=urn:btih:DC5E0F28C56CBB93E57FC11CA8E56CC79A5D2E13",
            "seed": 777,
            "peer": 276,
            "size": 1771674010,
            "filesize": "1.65 GB",
            "provider": "YTS"
        },
        "720p": {
            "url": "magnet:?xt=urn:btih:1C12E9D7A919113C923EF20089E7435890A12933",
            "seed": 611,
            "peer": 170,
            "size": 787847578,
            "filesize": "751.35 MB",
            "provider": "YTS"
        }
    }
}

we should use an appropiate format like this

"torrents": [{
    "language": "en",
    "qualities": [{
        "quality": "1080p",
        "url": "magnet:?xt=urn:btih:DC5E0F28C56CBB93E57FC11CA8E56CC79A5D2E13",
        "seed": 777,
        "peer": 276,
        "size": 1771674010,
        "filesize": "1.65 GB",
        "provider": "YTS"
    },
    {
        "quality": "720p",
        "url": "magnet:?xt=urn:btih:1C12E9D7A919113C923EF20089E7435890A12933",
        "seed": 611,
        "peer": 170,
        "size": 787847578,
        "filesize": "751.35 MB",
        "provider": "YTS"
    }]
},
{
    "language": "es",
    "qualities": [{
        "quality": "1080p",
        "url": "magnet:?xt=urn:btih:DC5E0F28C56CBB93E57FC11CA8E56CC79A5D2E13",
        "seed": 777,
        "peer": 276,
        "size": 1771674010,
        "filesize": "1.65 GB",
        "provider": "YTS"
    },
    {
        "quality": "720p",
        "url": "magnet:?xt=urn:btih:1C12E9D7A919113C923EF20089E7435890A12933",
        "seed": 611,
        "peer": 170,
        "size": 787847578,
        "filesize": "751.35 MB",
        "provider": "YTS"
    }]
}]

Obviously, this will cause an impact in the desktop and Android app response treatment.

ChrisAlderson commented 7 years ago

Is this specific to movies or also for shows and anime?

team-pct commented 7 years ago

I guess if we are doing it we do it for all

vzamanillo commented 7 years ago

@ChrisAlderson The comon torrent object has qualities as keys

Comon Torrents object

for movies has languages Movie Torrents object

but we should not use values as keys for all object.

ChrisAlderson commented 7 years ago

Won't fix since the butter-providers specs have advanced to use the the current form of torrents.