Closed brandan-schmitz closed 3 years ago
Human Readable String | API Quality String | ID |
---|---|---|
SD TV | sdtv | 1 |
SD DVD | sddvd | 2 |
HD TV | hdtv | 4 |
Raw HD TV | rawhdtv | 8 |
720p WEB-DL | hdwebdl | 32 |
720p BluRay | hdbluray | 128 |
1080p HD TV | fullhdtv | 16 |
1080p WEB-DL | fullhdwebdl | 64 |
1080p BlueRay | fullhdbluray | 256 |
2160p UHD 4K | uhd4kweb | 1024 |
User search for a show on the bot and select the appropriate show. It will be based off shows, not episodes.
Use TVDB ID of show user selected and add it to Sickgear:
http://10.0.10.17:8081/api/7929e2b3d33c385d3fad06f016281f83/?cmd=sg.show.addnew&indexer=1&indexerid=258541&status=wanted&upgrade_once=false&initial%5B%5D=hdwebdl&initial%5B%5D=hdbluray&initial%5B%5D=fullhdtv&initial%5B%5D=fullhdwebdl&initial%5B%5D=fullhdbluray
Indexerid is the TVDB ID. That should produce a return type like this:
{
"data": {
"name": "Chicago Fire"
},
"message": "Chicago Fire has been queued to be added",
"result": "success"
}
Display a message to the user stating the show has been added to the bot and any episodes that can be found will be added.
This process will need to be a scheduled task, and should run every 30 seconds. It will fetch the history from sickgear and add the history of snatched episodes to the bots download queue database so that the other peridic task, queue downloader, can download the episodes.
Make a request to sickgear's history API to fetch a list of snatched episode files:
http://10.0.10.17:8081/api/7929e2b3d33c385d3fad06f016281f83/?cmd=sg.history&type=snatched
That request should return a list of objects that look like this:
{
"data": [
{
"date": "2021-09-06 15:02",
"episode": 2,
"hide": 0,
"indexer": 1,
"indexerid": 258541,
"provider": "LimeTorrents",
"quality": "1080p WEB-DL",
"resource": "Chicago.Fire.S01E02.1080p.WEB-DL.DD5.1.H.264-KiNGS.[PublicHD]",
"resource_path": "",
"season": 1,
"show_name": "Chicago Fire",
"status": "Snatched",
"tvdbid": 258541,
"version": -1
}
],
"message": "",
"result": "success"
}
Parse the objects in the list add add them to a download queue table in the database. Important fields to save is episode, season, and tvdbid in addition to the resource field. This is the filename (minus the extension) of the downloaded torrent/magnet file. During this, multiple steps will need too occur.
.torrent
or a .magnet
file.This peridic task should run every 60 seconds and is responsible for fetching the next (oldest) file in the download queue and creating a download task for it. This should perform a check to make sure that there are no more than 4 (default) of these downloads running at any given time to avoid overloading the system. That number should be read from a config item so it can be adjusted without recompiling the program.
/torrents/addTorrent
endpoint (need to create this API method in the client). If it is a magnet file, read the first line of the magnet file then use the existing addMagnet()
function to add the magnet.Instead of deleting the queue item from the queue database when a work item is started, the database table should contain a field for the status of the item. Valid options should be queued, or processing. The bot should be able to verify that ones marked in the database as processing are indeed still processing. If they are not, it should check the file system to verify the file was completed otherwise it should set the status back to queued. This will make sure that if something gets interrupted that it does not get skipped or corrupted.
Closed with the release of v2.3.0
This will be difficult to do given most sites do not have API's that can be accessed. However looking at a project like (Torrents-API)[https://github.com/Ryuk-me/Torrents-Api} can help determine methods for obtaining that data.