Skip to content

Commit

Permalink
merge(release/1.3.0): lostfilm domain, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 5, 2023
2 parents e5b31e9 + f070ab3 commit ae4fa7e
Show file tree
Hide file tree
Showing 42 changed files with 2,120 additions and 2,050 deletions.
8 changes: 5 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.github
dist
node_modules
venv
out
MonitorrentInstaller
browsers
MonitorrentInstaller/
browsers/
tests/
.clients/
.artifacts/
29 changes: 29 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,35 @@ jobs:
draft: false
prerelease: false

- name: Find release zip in downloaded artifacts
id: find-release-zip
run: |
echo "release-zip=$(ls .artifacts/monitorrent-*.zip)" >> $GITHUB_OUTPUT
- name: Unzip release zip to dist folder
run: unzip ${{ steps.find-release-zip.outputs.release-zip }} -d ./dist

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build docker image
run: |-
sed "s/COPY --from=build/COPY --from=mount/g" Dockerfile | \
docker buildx build \
--platform linux/arm64,linux/amd64 \
-t werwolfby/monitorrent:${{ steps.extract-version.outputs.version }} \
-t werwolfby/monitorrent:latest \
--push -f - .
- name: Merge into develop
run: |
git checkout develop
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,5 @@ report.html
/MonitorrentInstaller/vcredist/
/MonitorrentInstaller/nssm/
/MonitorrentInstaller/nssm.zip

/.clients/
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ RUN npm install
COPY . /app
RUN gulp release

FROM scratch as export
FROM scratch AS export
COPY --from=build /app/monitorrent-*.zip .

FROM scratch AS mount
COPY . /app

FROM python:3.9.11-slim-bullseye
MAINTAINER Alexander Puzynia <[email protected]>

Expand All @@ -28,7 +31,7 @@ RUN dpkg -i /deb/fonts-ubuntu_0.83-2_all.deb && \
playwright install --with-deps firefox

# requirements.txt is changed not often and again for caching let's install it first
COPY requirements.txt /var/www/monitorrent/
COPY ./requirements.txt /var/www/monitorrent/
RUN pip install --no-cache-dir -r /var/www/monitorrent/requirements.txt && \
pip install --no-cache-dir PySocks

Expand Down
2 changes: 1 addition & 1 deletion MonitorrentInstaller/MonitorrentBundle/Bundle.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="Monitorrent Installer" Version="1.2.4.100" Manufacturer="Monitorrent Team" UpgradeCode="cb50686e-6598-4da5-95bc-b36151a7f4ed">
<Bundle Name="Monitorrent Installer" Version="1.3.0.100" Manufacturer="Monitorrent Team" UpgradeCode="cb50686e-6598-4da5-95bc-b36151a7f4ed">

<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
Expand Down
2 changes: 1 addition & 1 deletion MonitorrentInstaller/MonitorrentInstaller/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Monitorrent" Language="1033" Version="1.2.4.100" Manufacturer="Monitorrent Team" UpgradeCode="dd4cf505-1e44-4311-a8f2-efcf097175a7">
<Product Id="*" Name="Monitorrent" Language="1033" Version="1.3.0.100" Manufacturer="Monitorrent Team" UpgradeCode="dd4cf505-1e44-4311-a8f2-efcf097175a7">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="yes" />
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ Multiplatform image (`arm64` and `amd64` (`arm` is not supported anymore, until
[https://hub.docker.com/r/werwolfby/monitorrent/](https://hub.docker.com/r/werwolfby/monitorrent/)

### Windows Installer:
https://github.com/werwolfby/monitorrent/releases/download/1.2.4/MonitorrentInstaller-1.2.4.msi
https://github.com/werwolfby/monitorrent/releases/download/1.3.0/MonitorrentInstaller-1.3.0.msi

### Manual Install

Requirements:
- Python 3.9+ and pip

Download latest build: https://github.com/werwolfby/monitorrent/releases/download/1.2.4/monitorrent-1.2.4.zip
Download latest build: https://github.com/werwolfby/monitorrent/releases/download/1.3.0/monitorrent-1.3.0.zip
Extract into **monitorent** folder
* pip install -r requirements.txt
* playwright --with-deps install firefox
Expand Down
4 changes: 3 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Trackers:
- support www.lostfilm.tv tracking over parse topic page with topic quality support (new design support) and Cloudflare DDOS protection solving
- support www.lostfilm.tv tracking over parse topic page with topic quality support, Cloudflare DDOS protection solving and domain mirror support
- support www.rutor.org topic tracking
- support www.free-torrents.org topic tracking
- support www.rutracker.org topic tracking and Cloudflare DDOS protection solving
Expand Down Expand Up @@ -27,3 +27,5 @@

Fixes:
~~#383~~ 1.2.3 Windows - Not start
~~#384~~, ~~#374~~ КИНОЗАЛ перевести на https?
~~#350~~ Не удаляет предыдущую раздачу из qbittorrent в обновляемых раздачах
19 changes: 19 additions & 0 deletions docker-compose-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
version: "2.1"
services:
qbittorrent:
image: lscr.io/linuxserver/qbittorrent:latest
container_name: qbittorrent
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- WEBUI_PORT=8080
volumes:
- ./.clients/qbittorrent/config:/config
- ./.clients/qbittorrent/downloads:/downloads
ports:
- 8080:8080
- 6881:6881
- 6881:6881/udp
restart: unless-stopped
2 changes: 1 addition & 1 deletion monitorrent/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.4'
__version__ = '1.3.0'
22 changes: 20 additions & 2 deletions monitorrent/plugin_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def get_watching_topics(self):
watching_topics = []
with DBSession() as db:
dbtopics = db.query(Topic).all()
db.expunge_all()
for dbtopic in dbtopics:
try:
tracker = self.get_tracker(dbtopic.type)
Expand All @@ -163,14 +164,31 @@ def get_watching_topics(self):
# as just default topic, and show it disabled on UI to
# let user ability for delete such topics
continue

typed_topic = None

def get_typed_topic(dbtopic):
if typed_topic is not None:
return typed_topic
topic = db.query(tracker.topic_class).filter(Topic.id == dbtopic.id).first()
db.expunge(topic)
return topic

if hasattr(tracker, 'prepare_topic'):
typed_topic = get_typed_topic(dbtopic)
tracker.prepare_topic(typed_topic)

if typed_topic is not None:
dbtopic = typed_topic

topic = row2dict(dbtopic, None, ['id', 'url', 'display_name', 'last_update', 'paused'])
topic['info'] = tracker.get_topic_info(dbtopic)
topic['tracker'] = dbtopic.type
topic['status'] = dbtopic.status.__str__()

if hasattr(tracker, 'get_thumbnail_url'):
dbtopic = db.query(tracker.topic_class).filter(Topic.id == dbtopic.id).first()
topic['thumbnail_url'] = tracker.get_thumbnail_url(dbtopic)
typed_topic = get_typed_topic(dbtopic)
topic['thumbnail_url'] = tracker.get_thumbnail_url(typed_topic)

watching_topics.append(topic)
return watching_topics
Expand Down
38 changes: 30 additions & 8 deletions monitorrent/plugins/clients/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import unicode_literals

import six
import time

from pytz import utc
from sqlalchemy import Column, Integer, String
Expand All @@ -12,6 +13,7 @@

from monitorrent.db import Base, DBSession
from monitorrent.plugin_managers import register_plugin
from monitorrent.utils.bittorrent_ex import Torrent
from datetime import datetime


Expand Down Expand Up @@ -57,6 +59,12 @@ class QBittorrentClientPlugin(object):
DEFAULT_PORT = 8080
SUPPORTED_FIELDS = ['download_dir']
ADDRESS_FORMAT = "{0}:{1}"
_client = None

def get_client(self):
if not self._client:
self._client = self._get_client()
return self._client

def _get_client(self):
with DBSession() as db:
Expand Down Expand Up @@ -96,10 +104,15 @@ def set_settings(self, settings):
cred.password = settings.get('password', None)

def check_connection(self):
return self._get_client()
try:
client = self.get_client()
client.app_version()
return True
except:
return False

def find_torrent(self, torrent_hash):
client = self._get_client()
client = self.get_client()
if not client:
return False

Expand All @@ -117,7 +130,7 @@ def find_torrent(self, torrent_hash):
return False

def get_download_dir(self):
client = self._get_client()
client = self.get_client()
if not client:
return None

Expand All @@ -127,11 +140,11 @@ def get_download_dir(self):
except:
return None

def add_torrent(self, torrent, torrent_settings):
def add_torrent(self, torrent_content, torrent_settings):
"""
:type torrent_settings: clients.TopicSettings | None
"""
client = self._get_client()
client = self.get_client()
if not client:
return False

Expand All @@ -142,13 +155,22 @@ def add_torrent(self, torrent, torrent_settings):
savepath = torrent_settings.download_dir
auto_tmm = False

res = client.torrents_add(save_path=savepath, use_auto_torrent_management=auto_tmm, torrent_contents=[('file.torrent', torrent)])
return res
res = client.torrents_add(save_path=savepath, use_auto_torrent_management=auto_tmm, torrent_contents=[('file.torrent', torrent_content)])
if 'Ok' in res:
torrent = Torrent(torrent_content)
torrent_hash = torrent.info_hash
for i in range(0, 10):
found = self.find_torrent(torrent_hash)
if found:
return True
time.sleep(1)

return False
except:
return False

def remove_torrent(self, torrent_hash):
client = self._get_client()
client = self.get_client()
if not client:
return False

Expand Down
34 changes: 22 additions & 12 deletions monitorrent/plugins/trackers/kinozal.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class KinozalDateParser(object):
u'сегодня': 0,
u'вчера': -1
}
now_text = u'сейчас'
tz_moscow = pytz.timezone(u'Europe/Moscow')

def __init__(self):
Expand All @@ -95,6 +96,9 @@ def __init__(self):
self.time_parse_re = re.compile(pattern, re.UNICODE | re.IGNORECASE)

def parse(self, date_string):
if self.now_text in date_string:
return datetime.datetime.now(pytz.utc)

match = self.time_parse_re.match(date_string)
if not match:
raise Exception(u"Can't parse string: {0}".format(date_string))
Expand All @@ -120,10 +124,9 @@ def __init__(self, code, message):

class KinozalTracker(object):
tracker_settings = None
login_url = "http://kinozal.tv/takelogin.php"
profile_page = "http://kinozal.tv/inbox.php"
login_url = "https://kinozal.tv/takelogin.php"
profile_page = "https://kinozal.tv/inbox.php"
url_regex = re.compile(six.text_type(r'^https?://kinozal\.tv/details\.php\?id=(\d+)$'))
last_update_text_re = re.compile(u'^Торрент-файл обновлен\s+(.*)$', re.UNICODE | re.IGNORECASE)
date_parser = KinozalDateParser()

def __init__(self, c_uid=None, c_pass=None):
Expand Down Expand Up @@ -198,24 +201,31 @@ def get_last_torrent_update(self, url):
response.raise_for_status()

soup = get_soup(response.text)
content = soup.find("div", {"class": "mn1_content"})
last_update_text_element = content.find('b', text=self.last_update_text_re)
if last_update_text_element is None:
content = soup.find("div", {"class": "mn1_menu"})
text_element = content.find(lambda tag: (tag.name == 'li') and (u'Обновлен' in tag.contents))
date_text = None
if text_element is not None:
text_element = text_element.find("span")
if text_element is not None:
date_text = text_element.string
if date_text is None:
text_element = content.find(lambda tag: (tag.name == 'li') and (u'Залит' in tag.contents))
if text_element is not None:
text_element = text_element.find("span")
if text_element is not None:
date_text = text_element.string
if date_text is None:
return None

last_update_all_text = six.text_type(last_update_text_element.string)
last_update_text_match = self.last_update_text_re.match(last_update_all_text)
last_update_text = last_update_text_match.group(1)

parsed_datetime = self.date_parser.parse(last_update_text)
parsed_datetime = self.date_parser.parse(date_text)
return parsed_datetime.astimezone(pytz.utc)

def get_download_url(self, url):
torrent_id = self.get_id(url)
if torrent_id is None:
return None

return "http://dl.kinozal.tv/download.php?id=" + torrent_id
return "https://dl.kinozal.tv/download.php?id=" + torrent_id


class KinozalPlugin(WithCredentialsMixin, ExecuteWithHashChangeMixin, TrackerPluginBase):
Expand Down
Loading

0 comments on commit ae4fa7e

Please sign in to comment.