pax_global_header 0000666 0000000 0000000 00000000064 14575653726 0014536 g ustar 00root root 0000000 0000000 52 comment=5f3d558793b537a74480241ac6981479f5938cd3
woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-tapatalk/ 0000775 0000000 0000000 00000000000 14575653726 0023643 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-tapatalk/modules/ 0000775 0000000 0000000 00000000000 14575653726 0025313 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-tapatalk/modules/tapatalk/ 0000775 0000000 0000000 00000000000 14575653726 0027114 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-tapatalk/modules/tapatalk/__init__.py 0000664 0000000 0000000 00000001504 14575653726 0031225 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2016 Simon Lipp
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see
', msg) msg = re.sub(r'\[img\](.*?)\[/img\]', r'', msg) if post.get('icon_url'): return u' %s' % (xmlrpc_str(post['icon_url']), msg) else: return msg def _process_post(self, thread, post, is_root): message_id = is_root and u'0' or xmlrpc_str(post['post_id']) message_title = is_root and thread.title or u'Re: %s' % thread.title # Tapatalk app seems to have hardcoded this construction... I don't think we can do better :( rel_url = self.config['message_url_format'].get().format( thread_id = urllib.parse.quote(thread.id.encode('utf-8')), thread_title = urllib.parse.quote(thread.title.encode('utf-8')), message_id = urllib.parse.quote(message_id.encode('utf-8')), message_title = urllib.parse.quote(message_title.encode('utf-8'))) message = Message( id = message_id, thread = thread, sender = xmlrpc_str(post.get('post_author_name', u'Anonymous')), title = message_title, url = urllib.parse.urljoin(self.config['url'].get(), rel_url), receivers = None, date = self._get_time(post), content = self._format_content(post), signature = None, parent = thread.root or None, children = [], flags = Message.IS_HTML) if thread.root: thread.root.children.append(message) elif is_root: thread.root = message else: # First message in the thread is not the root message, # because we asked only for unread messages. Create a non-loaded root # message to allow monboob to fill correctly the References: header thread.root = Message(id=u'0', parent=None, children=[message], thread=thread) message.parent = thread.root return message def fill_thread(self, thread, fields, unread=False): def fill_root(thread, start, count, first_unread): while True: topic = self._conn.get_thread(thread.id, start, start+count-1, True) for i, post in enumerate(topic['posts']): message = self._process_post(thread, post, start*count+i == 0) if start+i >= first_unread: message.flags |= Message.IS_UNREAD start += count if start >= topic['total_post_num']: return thread count = 50 topic = self._conn.get_thread_by_unread(thread.id, count) if 'title' in fields: thread.title = xmlrpc_str(topic['topic_title']) if 'date' in fields: thread.date = self._get_time(topic) if 'root' in fields: # "position" starts at 1, whereas the "start" argument of get_thread starts at 0 pos = topic['position']-1 if unread: # start must be on a page boundary, or various (unpleasant) things will happen, # like get_threads returning nothing start = (pos//count)*count thread = fill_root(thread, start, count, pos) else: thread = fill_root(thread, 0, count, pos) return thread #### CapMessages ############################################## def get_thread(self, id): return self.fill_thread(Thread(id), ['title', 'root', 'date']) def iter_threads(self, unread=False): def browse_forum_mode(forum, prefix, mode): start = 0 count = 50 while True: if mode: topics = self._conn.get_topic(xmlrpc_str(forum['forum_id']), start, start+count-1, mode) else: topics = self._conn.get_topic(xmlrpc_str(forum['forum_id']), start, start+count-1) all_ignored = True for topic in topics['topics']: t = Thread(xmlrpc_str(topic['topic_id'])) t.title = xmlrpc_str(topic['topic_title']) t.date = self._get_time(topic) if not unread or topic.get('new_post'): all_ignored = False yield t start += count if start >= topics['total_topic_num'] or all_ignored: break def process_forum(forum, prefix): if (not unread or forum.get('new_post', True)) and not forum['sub_only']: for mode in ('TOP', 'ANN', None): for thread in browse_forum_mode(forum, prefix, mode): yield thread for child in forum.get('child', []): for thread in process_forum(child, u"%s.%s" % (prefix, xmlrpc_str(child['forum_name']))): yield thread for forum in self._conn.get_forum(): for thread in process_forum(forum, xmlrpc_str(forum['forum_name'])): yield thread def iter_unread_messages(self): for thread in self.iter_threads(unread=True): self.fill_thread(thread, ['root'], unread=True) for message in thread.iter_all_messages(): if message.flags & Message.IS_UNREAD: yield message def set_message_read(self, message): # No-op: the underlying forum will mark topics as read as we read them pass OBJECTS = {Thread: fill_thread} requirements.txt 0000664 0000000 0000000 00000000014 14575653726 0032314 0 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-tapatalk/modules/tapatalk woob ~= 3.2\1