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

Add gimmepeers torrent provider #6635

Merged
merged 36 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5b7cefb
Create gimmepeers.py
mystycs May 2, 2019
d6fdbfb
Update __init__.py
mystycs May 2, 2019
96aea44
Update __init__.py
mystycs May 2, 2019
9a9bbbe
Add files via upload
mystycs May 2, 2019
f27a874
Add files via upload
mystycs May 2, 2019
4f7037a
Update gimmepeers.py
mystycs May 2, 2019
6f600d2
run isort
mystycs May 2, 2019
379d179
Update gimmepeers.py
mystycs May 2, 2019
2943812
Update gimmepeers.py
mystycs May 2, 2019
9b1f1cf
make pep8 compliant for flake8 check
mystycs May 2, 2019
4400cad
Merge branch 'add_gimmepeers_provider' of github.com:mystycs/Medusa i…
mystycs May 2, 2019
54c1ffa
Update gimmepeers.py
mystycs May 2, 2019
1987145
pep8 fixes
mystycs May 2, 2019
2007463
Update gimmepeers.py
mystycs May 2, 2019
0d3da30
pep8 fixes
mystycs May 2, 2019
35af445
pep8 fix import order
mystycs May 2, 2019
716b056
revert isort
mystycs May 2, 2019
f39dbeb
revert isort
mystycs May 2, 2019
665224b
Add files via upload
mystycs May 2, 2019
6479d9f
pr fixes
mystycs May 2, 2019
d89b01a
pr fix minseed
mystycs May 2, 2019
da367a0
fix logger
mystycs May 2, 2019
8ee9887
remove logger since unused
mystycs May 2, 2019
265413d
Update gimmepeers.py
mystycs May 2, 2019
8f1f7a5
remove whitespace
mystycs May 2, 2019
65f9a22
replace format with urljoin
mystycs May 2, 2019
6259fc6
pr fixes + add pubdate
mystycs May 2, 2019
33667b4
pep8 whitespace fix
mystycs May 2, 2019
55192f0
pep8 whitespace fix
mystycs May 2, 2019
2d38ae7
fix size
mystycs May 2, 2019
be149ed
whitespace fix
mystycs May 2, 2019
533416c
remove trailing whitespace
mystycs May 2, 2019
8386aae
Small changes
medariox May 3, 2019
6cf0515
Optimize icon
medariox May 3, 2019
5f454f6
Update gimmepeers.py
medariox May 3, 2019
fa94fd4
Update CHANGELOG.md
p0psicles May 3, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### New Features
- Added nCore torrent provider ([#6537](https://github.com/pymedusa/Medusa/pull/6537))
- Added Gimmepeers torrent provider (credits to @mystycs) ([#6635](https://github.com/pymedusa/Medusa/pull/6635))

#### Improvements

Expand Down
3 changes: 2 additions & 1 deletion medusa/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
cinemaz,
danishbits,
elitetracker,
gimmepeers,
hdbits,
hdspace,
hdtorrents,
Expand Down Expand Up @@ -69,7 +70,7 @@
'abnormal', 'scenetime', 'nebulance', 'tvchaosuk', 'bitcannon', 'torrentz2', 'pretome', 'anizb',
'hdspace', 'nordicbits', 'danishbits', 'limetorrents', 'norbits', 'bithdtv', 'ncore',
'zooqle', 'animebytes', 'animetorrents', 'anidex', 'shanaproject', 'torrenting',
'yggtorrent', 'elitetracker', 'archetorrent', 'privatehd', 'cinemaz', 'avistaz', 'bjshare'
'yggtorrent', 'elitetracker', 'archetorrent', 'privatehd', 'cinemaz', 'avistaz', 'bjshare', 'gimmepeers'
]


Expand Down
3 changes: 2 additions & 1 deletion medusa/providers/torrent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
bjshare,
cinemaz,
elitetracker,
gimmepeers,
hdspace,
hdtorrents,
hebits,
Expand Down Expand Up @@ -69,5 +70,5 @@
'torrentbytes', 'torrentleech', 'nebulance', 'tvchaosuk', 'xthor', 'zooqle', 'bitcannon', 'btn',
'hdbits', 'norbits', 'rarbg', 'torrentday', 'nyaa', 'rsstorrent', 'shazbat', 'hebits',
'torrentz2', 'animetorrents', 'anidex', 'shanaproject', 'torrenting', 'yggtorrent',
'elitetracker', 'privatehd', 'cinemaz', 'avistaz', 'bjshare', 'ncore'
'elitetracker', 'privatehd', 'cinemaz', 'avistaz', 'bjshare', 'ncore', 'gimmepeers'
]
174 changes: 174 additions & 0 deletions medusa/providers/torrent/html/gimmepeers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# coding=utf-8

"""Provider code for GimmePeers."""

from __future__ import unicode_literals

import logging
import re

from medusa import tv
from medusa.bs4_parser import BS4Parser
from medusa.helper.common import convert_size
from medusa.logger.adapters.style import BraceAdapter
from medusa.providers.torrent.torrent_provider import TorrentProvider

from requests.compat import urljoin
from requests.utils import dict_from_cookiejar

log = BraceAdapter(logging.getLogger(__name__))
log.logger.addHandler(logging.NullHandler())


mystycs marked this conversation as resolved.
Show resolved Hide resolved
class GimmePeersProvider(TorrentProvider):
"""GimmePeers Torrent provider."""

def __init__(self):
"""Initialize the class."""
super(GimmePeersProvider, self).__init__('GimmePeers')

self.username = None
self.password = None

self.url = 'https://www.gimmepeers.com'
self.urls = {
'login': urljoin(self.url, 'takelogin.php'),
'search': urljoin(self.url, 'browse.php'),
}

# Proper Strings
self.proper_strings = ['PROPER', 'REPACK', 'REAL', 'RERIP']

self.cache = tv.Cache(self)

def search(self, search_strings, age=0, ep_obj=None, **kwargs):
"""
Search a provider and parse the results.

:param search_strings: A dict with mode (key) and the search value (value)
:param age: Not used
:param ep_obj: Not used
:returns: A list of search results (structure)
"""
results = []
if not self.login():
return results

search_params = {
'c20': 1,
'c21': 1,
'c25': 1,
'c24': 1,
'c23': 1,
'c22': 1,
'c1': 1,
}

for mode in search_strings:
log.debug('Search Mode: {0}', mode)

for search_string in search_strings[mode]:

if mode != 'RSS':
log.debug('Search string: {search}',
{'search': search_string})

search_params['search'] = search_string

response = self.session.get(self.urls['search'], params=search_params)
if not response or not response.text:
log.debug('No data returned from provider')
continue

results += self.parse(response.text, mode)

return results

def parse(self, data, mode):
"""
Parse search results for items.

:param data: The raw response from a search
:param mode: The current mode used to search, e.g. RSS
:return: A list of items found
"""
items = []

with BS4Parser(data, 'html5lib') as html:
torrent_table = html.find('table', class_='browsetable')
torrent_rows = torrent_table('tr') if torrent_table else []

# Continue only if one release is found
if len(torrent_rows) < 2:
log.debug('Data returned from provider does not contain any torrents')
return items

for result in torrent_rows[1:]:
cells = result('td')

try:
link = cells[1].find('a')
download_url = urljoin(self.url, cells[2].find('a')['href'])
title = link.get_text()
if not all([title, download_url]):
mystycs marked this conversation as resolved.
Show resolved Hide resolved
continue

seeders = int(cells[10].get_text().replace(',', ''))
leechers = int(cells[11].get_text().replace(',', ''))

# Filter unseeded torrent
if seeders < self.minseed:
if mode != 'RSS':
log.debug("Discarding torrent because it doesn't meet the"
' minimum seeders: {0}. Seeders: {1}',
title, seeders)
continue

torrent_size = cells[5].get_text(' ')
size = convert_size(torrent_size) or -1

pubdate_raw = cells[6].get_text()
pubdate = self.parse_pubdate(pubdate_raw)

item = {
'title': title,
'link': download_url,
'size': size,
'seeders': seeders,
'leechers': leechers,
'pubdate': pubdate,
}
if mode != 'RSS':
log.debug('Found result: {0} with {1} seeders and {2} leechers',
title, seeders, leechers)

items.append(item)
except (AttributeError, TypeError, KeyError, ValueError, IndexError):
log.exception('Failed parsing provider.')

return items

def login(self):
"""Login method used for logging in before doing search and torrent downloads."""
if any(dict_from_cookiejar(self.session.cookies).values()):
return True

login_params = {
'username': self.username,
'password': self.password,
'ssl': 'yes',
}

response = self.session.post(self.urls['login'], data=login_params)
if not response or not response.text:
log.debug('Unable to connect to provider')
return False

if re.search('Username or password incorrect!', response.text):
log.debug('Invalid username or password. Check your settings')
return False

return True


provider = GimmePeersProvider()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added themes/dark/assets/img/providers/gimmepeers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added themes/light/assets/img/providers/gimmepeers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.