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 21 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
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'
]
167 changes: 167 additions & 0 deletions medusa/providers/torrent/html/gimmepeers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# coding=utf-8

"""Provider code for GimmePeers."""

from __future__ import unicode_literals

import re

from medusa import logger, tv
from medusa.bs4_parser import BS4Parser
from medusa.helper.common import convert_size
from medusa.providers.torrent.torrent_provider import TorrentProvider

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


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

def __init__(self):

TorrentProvider.__init__(self, 'GimmePeers')

self.url = 'https://www.gimmepeers.com'
self.urls = {
'login': urljoin(self.url, 'takelogin.php'),
'search': urljoin(self.url, 'browse.php'),
'download': urljoin(self.url, '%s'),
mystycs marked this conversation as resolved.
Show resolved Hide resolved
}

self.username = None
self.password = None

self.cache = tv.Cache(self)

self.search_params = {
mystycs marked this conversation as resolved.
Show resolved Hide resolved
'c20': 1,
'c21': 1,
'c25': 1,
'c24': 1,
'c23': 1,
'c22': 1,
'c1': 1
}

def search(self, search_strings, age=0, ep_obj=None, **kwargs): # pylint: disable=too-many-locals
"""
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

for mode in search_strings:

logger.log(u'Search Mode: {0}'.format(mode), logger.DEBUG)
for search_string in search_strings[mode]:
if mode != 'RSS':
logger.log(u'Search string: {0}'.format
(search_string), logger.DEBUG)

self.search_params['search'] = search_string

data = self.session.get(self.urls['search'], params=self.search_params)
if not data:
mystycs marked this conversation as resolved.
Show resolved Hide resolved
continue

results += self.parse(data.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:
logger.log(u'Data returned from provider does not contain any torrents', logger.DEBUG)
return items

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

link = cells[1].find('a')
download_url = self.urls['download'] % cells[2].find('a')['href']
mystycs marked this conversation as resolved.
Show resolved Hide resolved
title = link.getText()
mystycs marked this conversation as resolved.
Show resolved Hide resolved

if not all([title, download_url]):
continue

seeders = int(cells[10].getText().replace(',', ''))
leechers = int(cells[11].getText().replace(',', ''))
torrent_size = cells[8].getText()
size = convert_size(torrent_size) or -1

# 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

item = {
'title': title,
'link': download_url,
'size': size,
'seeders': seeders,
'leechers': leechers,
'hash': '',
mystycs marked this conversation as resolved.
Show resolved Hide resolved
}
if mode != 'RSS':
logger.debug('Found result: {0} with {1} seeders and {2} leechers',
title, seeders, leechers)

items.append(item)

except (AttributeError, TypeError, KeyError, ValueError, IndexError):
logger.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:
logger.log(u'Unable to connect to provider', logger.WARNING)
return False

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

return True

def _check_auth(self):
if not self.username or not self.password:
logger.log(u'Invalid username or password. Check your settings', logger.WARNING)

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.