[Schema change] Add webseed support (BEP-19) (#317)

Store webseeds in Trackers table with is_webseed flag
Adjusts torrent creation accordingly
This commit is contained in:
Anna-Maria Meriniemi
2017-07-30 00:00:39 +03:00
committed by GitHub
parent 8a4793ffb0
commit 1bc36c5a17
5 changed files with 80 additions and 7 deletions

View File

@@ -343,6 +343,16 @@ def _validate_trackers(torrent_dict, tracker_to_check_for=None):
return tracker_found
# http://www.bittorrent.org/beps/bep_0019.html
def _validate_webseeds(torrent_dict):
webseed_list = torrent_dict.get('url-list')
if webseed_list is not None:
_validate_list(webseed_list, 'url-list')
for webseed_url in webseed_list:
_validate_bytes(webseed_url, 'url-list item', test_decode='utf-8')
def _validate_torrent_metadata(torrent_dict):
''' Validates a torrent metadata dict, raising AssertionError on errors '''
assert isinstance(torrent_dict, dict), 'torrent metadata is not a dict'
@@ -384,6 +394,8 @@ def _validate_torrent_metadata(torrent_dict):
length = info_dict.get('length')
_validate_number(length, 'length', check_positive=True)
_validate_webseeds(torrent_dict)
def _validate_bytes(value, name='value', check_empty=True, test_decode=None):
assert isinstance(value, bytes), name + ' is not bytes'