def connection_thread(self, conn, id, i):
     message = json.dumps({
         "TYPE": "CALIBRATION",
         "PAYLOAD": str(i)
     })
     self.calibrations[id][i]["server_send"] = time.time()
     conn.sendall(string_to_byte(message) + self.SPECIAL_KEYWORD)
Esempio n. 2
0
 def search(self, query):
     search_url = self.base_url
     payload = {
         'page': 'search',
         'term': query,
         'sort': '2',
         'cats': '1_0',
         'filter': '0'
     }
     torrents = []
     response = requests.get(search_url,
                             params=payload,
                             headers=self.headers).text
     soup = bs(response, "lxml")
     table = soup.find('table', class_='tlist')
     for tr in table.find_all('tr')[1:]:
         t = Torrent()
         cols = tr.findAll('td')
         t.title = cols[1].find('a').text
         size = cols[3].text
         t.size = string_to_byte(size)
         t.seeds = cols[4].text
         t.torrent_url = cols[2].find('a').get('href') + "&magnet=1"
         torrents.append(t)
     return torrents
    def send_id(self, id):
        conn = self.active_connections[id]

        message = {"TYPE": "ID", "PAYLOAD": id}

        print(f"Sending ID to the Player {id}")

        conn.sendall(
            string_to_byte(json.dumps(message)) + self.SPECIAL_KEYWORD)
Esempio n. 4
0
 def _parse_page(self, page_text):
     soup = BS(page_text, "lxml")
     torrents = []
     lines = soup.find_all(class_='ligne0') + soup.find_all(class_='ligne1')
     for line in lines:
         t = Torrent()
         t.title = line.find('a').text
         size = line.find(class_='poid').text
         t.size = string_to_byte(size)
         t.seeds = int(line.find(class_='seed_ok').text)
         t.torrent_url = self._torrent_link(line.find('a').get('href'))
         torrents.append(t)
     return torrents
Esempio n. 5
0
 def _parse_page(self, page_text):
     soup = BS(page_text, "lxml")
     torrents = []
     lines = soup.find_all(class_='ligne0')+soup.find_all(class_='ligne1')
     for line in lines:
         t = Torrent()
         t.title = line.find('a').text
         size = line.find(class_='poid').text
         t.size = string_to_byte(size)
         t.seeds = int(line.find(class_='seed_ok').text)
         t.torrent_url = self._torrent_link(line.find('a').get('href'))
         torrents.append(t)
     return torrents
Esempio n. 6
0
 def get_top(self):
     search_url = self.base_url + "/movies"
     data = requests.get(search_url, headers=self.headers).text
     soup = BS(data, "lxml")
     torrents = []
     table = soup.find(class_="data")
     for row in table.find_all("tr")[1:]:
         cells = row.find_all("td")
         t = Torrent()
         t.title = cells[0].find(class_="cellMainLink").text
         t.torrent_url = cells[0].find_all("a")[3].get("href")
         t.size = string_to_byte(cells[1].text)
         t.seeds = int(cells[4].text)
         torrents.append(t)
     return torrents
Esempio n. 7
0
 def get_top(self):
     search_url = self.base_url + '/movies'
     data = requests.get(search_url, headers=self.headers).text
     soup = BS(data, 'lxml')
     torrents = []
     table = soup.find(class_='data')
     for row in table.find_all('tr')[1:]:
         cells = row.find_all('td')
         t = Torrent()
         t.title = cells[0].find(class_='cellMainLink').text
         t.torrent_url = cells[0].find_all('a')[3].get('href')
         t.size = string_to_byte(cells[1].text)
         t.seeds = int(cells[4].text)
         torrents.append(t)
     return torrents
Esempio n. 8
0
 def _parse_page(self, page_text):
     soup = BS(page_text, "lxml")
     torrents = []
     table = soup.find(id="searchResult")
     for row in table.find_all('tr')[1:30]:
         t = Torrent()
         cells = row.find_all('td')
         a = cells[1].find_all('a')
         t.title = a[0].text
         t.torrent_url = a[1]['href']
         t.seeds = int(cells[2].text)
         pattern = re.compile("Uploaded (.*), Size (.*), ULed by (.*)")
         match = pattern.match(cells[1].font.text)
         size = match.groups()[1].replace('xa0', ' ')
         t.size = string_to_byte(size)
         torrents.append(t)
     return torrents
Esempio n. 9
0
 def _parse_page(self, page_text):
     soup = BS(page_text, "lxml")
     torrents = []
     table = soup.find(id="searchResult")
     for row in table.find_all('tr')[1:30]:
         t = Torrent()
         cells = row.find_all('td')
         a = cells[1].find_all('a')
         t.title = a[0].text
         t.torrent_url = a[1]['href']
         t.seeds = int(cells[2].text)
         pattern = re.compile("Uploaded (.*), Size (.*), ULed by (.*)")
         match = pattern.match(cells[1].font.text)
         size = match.groups()[1].replace('xa0', ' ')
         t.size = string_to_byte(size)
         torrents.append(t)
     return torrents
Esempio n. 10
0
 def search(self, query):
     search_url = self.base_url
     payload = {'page': 'search', 'term': query,
                'sort': '2', 'cats': '1_0', 'filter': '0'}
     torrents = []
     response = requests.get(
         search_url, params=payload, headers=self.headers).text
     soup = bs(response, "lxml")
     table = soup.find('table', class_='tlist')
     for tr in table.find_all('tr')[1:]:
         t = Torrent()
         cols = tr.findAll('td')
         t.title = cols[1].find('a').text
         size = cols[3].text
         t.size = string_to_byte(size)
         t.seeds = cols[4].text
         t.torrent_url = cols[2].find('a').get('href')+"&magnet=1"
         torrents.append(t)
     return torrents
Esempio n. 11
0
def send_message(message_to_send):
    message_to_send = message_to_send + "xaxaxayarmaW"
    try:
        SERVER.sendall(utils.string_to_byte(message_to_send))
    except:
        print("Message could not be sent.")