Exemple #1
0
    def sendFile(self):
        session = loadSession()

        link = session.query(SearchData).filter(
            SearchData.song_link.ilike('%' + self.mes_text + '%')).order_by(
                desc(SearchData.id)).first().song_link
        payload = {'chat_id': self.chat_id, 'audio': link}
        self.sendTgrmRequest(BOTURL_AUDIO, payload)
Exemple #2
0
    def makeResults(self, data):
        self.search_result = data.find_all(class_='playlist__item', limit=5)
        self.reslist = []
        for x in self.search_result:  # наполнение массива словарями  песен
            curdict = {}
            curdict['song'] = x.attrs['data-name']
            curdict['author'] = x.attrs['data-artist']
            curdict['link'] = x.find("a", class_="dl-song")['href']
            curdict['info'] = []
            for c in x.find_all("span", class_="text-muted"):
                curdict['info'].append(c.get_text())
            self.reslist.append(curdict)

        for y in self.reslist:  # получаем полные ссылки на песни
            result = self.site_request(SITE_URL + y['link'])

            div = result.find("div", "playlist__actions")

            resultRef = div.find("a", class_="no-ajaxy yaBrowser")
            if resultRef is None:  #если на целевой странице нет ссылки на песню
                y['filelink'] = 'empty'
                continue
            resultRef = resultRef['href']
            y['filelink'] = SITE_URL + str(resultRef)
            session = loadSession()
            new_searchData = SearchData(song_short=y['link'],
                                        song_link=y['filelink'])
            session.add(new_searchData)
            session.commit()
        self.res_text = ""
        for a in self.reslist:
            if a['filelink'] != 'empty':  # не обрабатываем песню без ссылки
                a['mod_link'] = re.sub(r'^.*?\/.*?(\/.*?)\/.*$', r'\1',
                                       a['link'])
                self.res_text += '<b>' + a['author'] + '</b>' + '\n'
                self.res_text += a['song'] + '\n'
                self.res_text += a['info'][0] + '  ' + '<i>' + a['info'][
                    1] + '</i>' + '\n'
                self.res_text += '<i>Download:</i>' + a['mod_link'] + '\n\n'
Exemple #3
0
def getSession():
    g.session = db.loadSession()