Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused "id" field from parser and api_format #441

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions burst/burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ def extract_torrents(provider, client):

dom = Html().feed(client.content)

id_search = get_search_query(definition, "id")
key_search = get_search_query(definition, "key")
row_search = get_search_query(definition, "row")
name_search = get_search_query(definition, "name")
Expand All @@ -301,7 +300,7 @@ def extract_torrents(provider, client):
needs_subpage = 'subpage' in definition and definition['subpage']

if needs_subpage:
def extract_subpage(q, id, name, torrent, size, seeds, peers, info_hash, referer):
def extract_subpage(q, name, torrent, size, seeds, peers, info_hash, referer):
try:
log.debug("[%s] Getting subpage at %s" % (provider, repr(torrent)))
except Exception as e:
Expand Down Expand Up @@ -340,7 +339,7 @@ def extract_subpage(q, id, name, torrent, size, seeds, peers, info_hash, referer
map(log.debug, traceback.format_exc().split("\n"))

log.debug("[%s] Subpage torrent for %s: %s" % (provider, repr(uri[0]), torrent))
ret = (id, name, info_hash, torrent, size, seeds, peers)
ret = (name, info_hash, torrent, size, seeds, peers)

# Cache this subpage result if another query would need to request same url.
provider_cache[uri[0]] = torrent
Expand Down Expand Up @@ -373,7 +372,6 @@ def extract_subpage(q, id, name, torrent, size, seeds, peers, info_hash, referer
continue

try:
id = eval(id_search) if id_search else ""
name = eval(name_search) if name_search else ""
description = eval(description_search) if description_search else ""
torrent = eval(torrent_search) if torrent_search else ""
Expand All @@ -387,7 +385,6 @@ def extract_subpage(q, id, name, torrent, size, seeds, peers, info_hash, referer
torrent = torrent[torrent.find('magnet:?'):]

if debug_parser:
log.debug("[%s] Parser debug | Matched '%s' iteration for query '%s': %s" % (provider, 'id', id_search, id))
log.debug("[%s] Parser debug | Matched '%s' iteration for query '%s': %s" % (provider, 'name', name_search, name))
log.debug("[%s] Parser debug | Matched '%s' iteration for query '%s': %s" % (provider, 'description', description_search, description))
log.debug("[%s] Parser debug | Matched '%s' iteration for query '%s': %s" % (provider, 'torrent', torrent_search, torrent))
Expand Down Expand Up @@ -459,13 +456,13 @@ def extract_subpage(q, id, name, torrent, size, seeds, peers, info_hash, referer
# Check if this url was previously requested, to avoid doing same job again.
uri = torrent.split('|')
if uri and uri[0] and uri[0] in provider_cache and provider_cache[uri[0]]:
yield (id, name, info_hash, provider_cache[uri[0]], size, seeds, peers)
yield (name, info_hash, provider_cache[uri[0]], size, seeds, peers)
continue

t = Thread(target=extract_subpage, args=(q, id, name, torrent, size, seeds, peers, info_hash, referer))
t = Thread(target=extract_subpage, args=(q, name, torrent, size, seeds, peers, info_hash, referer))
threads.append(t)
else:
yield (id, name, info_hash, torrent, size, seeds, peers)
yield (name, info_hash, torrent, size, seeds, peers)
except Exception as e:
log.error("[%s] Got an exception while parsing results: %s" % (provider, repr(e)))

Expand Down Expand Up @@ -546,15 +543,12 @@ def get_nested_value(result, key, default):
for result in results:
if not result or not isinstance(result, dict):
continue
id = ''
name = ''
info_hash = ''
torrent = ''
size = ''
seeds = ''
peers = ''
if 'id' in api_format:
id = result[api_format['id']]
if 'name' in api_format:
name = get_nested_value(result, api_format['name'], "")
if 'description' in api_format:
Expand Down Expand Up @@ -589,7 +583,7 @@ def get_nested_value(result, key, default):
peers = result[api_format['peers']]
if isinstance(peers, basestring) and peers.isdigit():
peers = int(peers)
yield (id, name, info_hash, torrent, size, seeds, peers)
yield (name, info_hash, torrent, size, seeds, peers)


def extract_from_page(provider, content):
Expand Down
3 changes: 1 addition & 2 deletions burst/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def generate_payload(provider, generator, filtering, verify_name=True, verify_si
definition = definitions[provider]
definition = get_alias(definition, get_setting("%s_alias" % provider))

for id, name, info_hash, uri, size, seeds, peers in generator:
for name, info_hash, uri, size, seeds, peers in generator:
size = clean_size(size)
# uri, info_hash = clean_magnet(uri, info_hash)
v_name = name if verify_name else filtering.title
Expand All @@ -53,7 +53,6 @@ def generate_payload(provider, generator, filtering, verify_name=True, verify_si
sort_balance = (sort_seeds + 1) * 3 * sort_resolution

results.append({
"id": id,
"name": name,
"uri": uri,
"info_hash": info_hash,
Expand Down