Skip to content

Commit

Permalink
Merge pull request #90 from ragmehos/develop
Browse files Browse the repository at this point in the history
Add magnet links to bitsearch during parsing
  • Loading branch information
mhdzumair authored Jan 28, 2024
2 parents b26ed97 + 83bd7c8 commit 098a921
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scrappers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

import cloudscraper
import httpx
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
Expand Down Expand Up @@ -101,3 +102,14 @@ def get_scrapper_config(site_name: str, get_key: str) -> dict:
config = json.load(file)

return config.get(site_name, {}).get(get_key, {})


async def add_to_bitsearch(magnet_link: str):
async with httpx.AsyncClient() as client:
response = await client.post(
"https://bitsearch.to/add-torrent", data={'infohash': magnet_link}
)
if response.status_code == 200:
logging.info(f"Added {magnet_link} to bitsearch")
else:
logging.error(f"Failed to add magnet link {magnet_link}: {response.status_code}")
6 changes: 6 additions & 0 deletions scrappers/tamil_blasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
get_scrapper_session,
download_and_save_torrent,
get_scrapper_config,
add_to_bitsearch,
)

HOMEPAGE = get_scrapper_config("tamil_blasters", "homepage")
Expand Down Expand Up @@ -92,6 +93,7 @@ async def process_movie(

# Extracting torrent details
torrent_elements = movie_page.select("a[data-fileext='torrent']")
magnet_elements = movie_page.select("a[class='magnet-plugin']")

if not torrent_elements:
logging.error(f"No torrents found for {page_link}")
Expand All @@ -113,6 +115,10 @@ async def process_movie(
exc_info=True,
stack_info=True,
)
if magnet_elements:
for magnet_element in magnet_elements:
magnet_link = magnet_element.get("href")
await add_to_bitsearch(magnet_link)

return True
except Exception as e:
Expand Down
6 changes: 6 additions & 0 deletions scrappers/tamilmv.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
get_scrapper_session,
download_and_save_torrent,
get_scrapper_config,
add_to_bitsearch,
)

HOMEPAGE = get_scrapper_config("tamilmv", "homepage")
Expand Down Expand Up @@ -82,6 +83,7 @@ async def process_movie(

# Extracting torrent details
torrent_elements = movie_page.select("a[data-fileext='torrent']")
magnet_elements = movie_page.select("a[class='skyblue-button']")

if not torrent_elements:
logging.error(f"No torrents found for {page_link}")
Expand All @@ -96,6 +98,10 @@ async def process_movie(
media_type=media_type,
page_link=page_link,
)
if magnet_elements:
for magnet_element in magnet_elements:
magnet_link = magnet_element.get("href")
await add_to_bitsearch(magnet_link)

return True
except Exception as e:
Expand Down

0 comments on commit 098a921

Please sign in to comment.