Пример #1
0
    def _smsc_send_cmd(self, cmd, arg=""):
        url = ifs(current_app.config['SMSC_HTTPS'], "https", "http") + "://smsc.ru/sys/" + cmd + ".php"
        _url = url
        arg = "login="******"&psw=" + quote(current_app.config['SMSC_PASSWORD']) + "&fmt=1&charset=" + current_app.config['SMSC_CHARSET'] + "&" + arg
        
        errors = {
            1: 'Ошибка в параметрах.',
            2: 'Неверный логин или пароль.',
            3: 'Недостаточно средств на счете Клиента.',
            4: 'IP-адрес временно заблокирован из-за частых ошибок в запросах. Подробнее',
            5: 'Неверный формат даты.',
            6: 'Сообщение запрещено (по тексту или по имени отправителя).',
            7: 'Неверный формат номера телефона.',
            8: 'Сообщение на указанный номер не может быть доставлено.',
            9: 'Отправка более одного одинакового запроса на передачу SMS-сообщения либо более пяти одинаковых запросов на получение стоимости сообщения в течение минуты. '
            }



        i = 0
        ret = ""

        while ret == "" and i <= 5:
            if i > 0:
                url = _url.replace("smsc.ru/", "www" + str(i) + ".smsc.ru/")
                
            else:
                i += 1            
            try:
                if current_app.config['SMSC_POST'] or len(arg) > 2000:
                    data = urlopen(url, arg.encode(current_app.config['SMSC_CHARSET']))
                else:                    
                    data = urlopen(url + "?" + arg)  
                    
                ret = str(data.read().decode(current_app.config['SMSC_CHARSET']))
                
            except:
                ret = ""
      
            i += 1

        if ret == "":
            if current_app.config['SMSC_DEBUG']:
                print("Ошибка чтения адреса: " + url)
            ret = "," # фиктивный ответ

        return ret.split(",")


    # Examples:
# smsc = SMSC()
# smsc.send_sms("79999999999", "test", sender="sms")
# smsc.send_sms("79999999999", "http://smsc.ru\nSMSC.RU", query="maxsms=3")
# smsc.send_sms("79999999999", "0605040B8423F0DC0601AE02056A0045C60C036D79736974652E72750001036D7973697465000101", format=5)
# smsc.send_sms("79999999999", "", format=3)
# r = smsc.get_sms_cost("79999999999", "Вы успешно зарегистрированы!")
# smsc.send_sms_mail("79999999999", "test2", format=1)
# r = smsc.get_status(12345, "79999999999")
# print(smsc.get_balance())
Пример #2
0
    def grab_torrents(self, search_string):
        self._torrentItems = []
        data = None
        try:
            kickass = Host(self.baseUrl)
            data = kickass.open_path(self.path % quote(sub_special_tags(search_string)), "https", self.timeout)
        except urllib_errors.HTTPError as e:
            self.logger.warning("%s, url=%s", e, self.baseUrl % quote(sub_special_tags(search_string)))

        if data:
            self.parse(data, search_string)
Пример #3
0
    def send_sms(self, phones, message, translit=0, time="", id=0, format=0, sender=False, query=""):
        formats = ["flash=1", "push=1", "hlr=1", "bin=1", "bin=2", "ping=1", "mms=1", "mail=1", "call=1", "viber=1", "soc=1"]

        m = self._smsc_send_cmd("send", 
                               "cost=3&phones=" + quote(phones) + "&mes=" + quote(message) + "&translit=" + str(translit) + \
                               "&id=" + str(id) + ifs(format > 0, "&" + formats[format-1], "") + ifs(sender == False, "", "&sender=" + \
                               quote(str(sender))) + ifs(time, "&time=" + quote(time), "") + \
                               ifs(query, "&" + query, ""))

        # (id, cnt, cost, balance) или (id, -error)

        if current_app.config['SMSC_DEBUG']:
            if m[1] > "0":
                print("Сообщение отправлено успешно. ID: " + m[0] + ", всего SMS: " + m[1] + ", стоимость: " + m[2] + ", баланс: " + m[3])
            else:
                print("Ошибка №" + m[1][1:] + ifs(m[0] > "0", ", ID: " + m[0], ""))

        return m
Пример #4
0
    def get_sms_cost(self, phones, message, translit=0, format=0, sender=False, query=""):
        
        formats = ["flash=1", "push=1", "hlr=1", "bin=1", "bin=2", "ping=1", "mms=1", "mail=1", "call=1", "viber=1", "soc=1"]
        #_smsc_send_cmd(self, cmd, arg=""):
        
        m = self._smsc_send_cmd("send", 
                                "cost=1&phones=" + quote(phones) + "&mes=" + quote(message) + ifs(sender == False, "", "&sender=" + quote(str(sender))) + "&translit=" + str(translit) + ifs(format > 0, "&" + formats[format-1], "") + ifs(query, "&" + query, "")
                                )        
        
        if current_app.config['SMSC_DEBUG']:
          #  print ('debug')
            if m[1] > "0":
                print("Стоимость рассылки: " + m[0] + ". Всего SMS: " + m[1])
            else:
             #   print ('UNdebug')
                print("Ошибка №" + m[1][1:])

        return m
Пример #5
0
 def get_source(self, search_string):
     try:
         return MultiHostHandler.Instance().open_url(
             "https://%s/search/%s/0/7/0" % (self.host, quote(sub_special_tags(search_string))),
             self.timeout
         )
     except MultiHostHandlerException as e:
         self.logger.warning(e)
     return None
Пример #6
0
 def make_magnet(ih, name):
     mg = 'magnet:?xt=urn:btih:%s&dn=%s' % (ih, name)
     mg += '&tr=' + quote('udp://tracker.coppersurfer.tk:6969/announce')
     mg += '&tr=' + quote('udp://9.rarbg.to:2920/announce')
     mg += '&tr=' + quote('udp://tracker.opentrackr.org:1337')
     mg += '&tr=' + quote('udp://tracker.internetwarriors.net:1337/announce')
     mg += '&tr=' + quote('udp://tracker.leechers-paradise.org:6969/announce')
     mg += '&tr=' + quote('udp://tracker.coppersurfer.tk:6969/announce')
     mg += '&tr=' + quote('udp://tracker.pirateparty.gr:6969/announce')
     mg += '&tr=' + quote('udp://tracker.cyberia.is:6969/announce')
     return mg
Пример #7
0
    def grab_torrents(self, search_string):
        self._torrentItems = []

        data_raw = MultiHostHandler.Instance().open_url(
            "https://%s/q.php?q=%s&cat=0" % (self.host, quote(sub_special_tags(search_string))),
            self.timeout
        )

        data = json.loads(data_raw)

        # 0
        # id	"36096995"
        # name	"Richard.Jewell.2019.1080p.WEBRip.x264.AAC5.1"
        # info_hash	"8679D25AB5B5BEA4239A05CD40BEF27C49C4E453"
        # leechers	"54"
        # seeders	"461"
        # num_files	"3"
        # size	"2496200363"
        # username	"SeekNDstroy"
        # added	"1583363396"
        # status	"member"
        # category	"207"
        # imdb	"tt3513548"
        # total_found	"52"

        def make_magnet(ih, name):
            mg = 'magnet:?xt=urn:btih:%s&dn=%s' % (ih, name)
            mg += '&tr=' + quote('udp://tracker.coppersurfer.tk:6969/announce')
            mg += '&tr=' + quote('udp://9.rarbg.to:2920/announce')
            mg += '&tr=' + quote('udp://tracker.opentrackr.org:1337')
            mg += '&tr=' + quote('udp://tracker.internetwarriors.net:1337/announce')
            mg += '&tr=' + quote('udp://tracker.leechers-paradise.org:6969/announce')
            mg += '&tr=' + quote('udp://tracker.coppersurfer.tk:6969/announce')
            mg += '&tr=' + quote('udp://tracker.pirateparty.gr:6969/announce')
            mg += '&tr=' + quote('udp://tracker.cyberia.is:6969/announce')
            return mg

        for torrent_item in data:
            if torrent_item["status"] in ["trusted", "vip"]:

                name = torrent_item["name"]

                magnet = make_magnet(torrent_item["info_hash"], name)

                item = TorrentItem(
                    link=magnet,
                    title=name,
                    seeds=int(torrent_item["seeders"]),
                    leeches=int(torrent_item["leechers"]),
                    size=int(torrent_item["size"]),
                    author=torrent_item["username"]
                )

                item.content = TorrentContent(magnet, ctype=TorrentContent.TYPE_MAGNET)
                self._torrentItems.append(item)
Пример #8
0
    def grab_torrents(self, search_string):
        self._torrentItems = []
        source = None

        try:
            params = dict(
                search=quote_plus(search_string),
                order="seeder",
                type="desc",
                cat=210
            )
            resp = self.session.get(self.host + self.search_url, params=params, timeout=self.timeout)
            if resp.ok:
                source = resp.text
        except urllib_errors.HTTPError as e:
            self.logger.warning("%s, url=%s", e, self.baseUrl % quote(sub_special_tags(search_string)))

        if source:
            self.parse(source, search_string)
Пример #9
0
    def get_status(self, id, phone, all = 0):
        m = self._smsc_send_cmd("status", "phone=" + quote(phone) + "&id=" + str(id) + "&all=" + str(all))
        
        # (status, time, err, ...) или (0, -error)

        if current_app.config['SMSC_DEBUG']:
            if m[1] >= "0":
                tm = ""
                if m[1] > "0":
                    tm = str(datetime.fromtimestamp(int(m[1])))
                print("Статус SMS = " + m[0] + ifs(m[1] > "0", ", время изменения статуса - " + tm, ""))
            else:
                print("Ошибка №" + m[1][1:])

        if all and len(m) > 9 and (len(m) < 14 or m[14] != "HLR"):
            m = (",".join(m)).split(",", 8)



        return m