Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1"""LICENSE 

2Copyright 2016 Hermann Krumrey <hermann@krumreyh.com> 

3 

4This file is part of xdcc-dl. 

5 

6xdcc-dl is free software: you can redistribute it and/or modify 

7it under the terms of the GNU General Public License as published by 

8the Free Software Foundation, either version 3 of the License, or 

9(at your option) any later version. 

10 

11xdcc-dl is distributed in the hope that it will be useful, 

12but WITHOUT ANY WARRANTY; without even the implied warranty of 

13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

14GNU General Public License for more details. 

15 

16You should have received a copy of the GNU General Public License 

17along with xdcc-dl. If not, see <http://www.gnu.org/licenses/>. 

18LICENSE""" 

19 

20import requests 

21from typing import List 

22from bs4 import BeautifulSoup 

23from xdcc_dl.entities.XDCCPack import XDCCPack 

24from xdcc_dl.entities.IrcServer import IrcServer 

25from puffotter.units import byte_string_to_byte_count 

26 

27 

28def find_xdcc_eu_packs(search_phrase: str) -> List[XDCCPack]: 

29 """ 

30 Method that conducts the xdcc pack search for xdcc.eu 

31 

32 :return: the search results as a list of XDCCPack objects 

33 """ 

34 url = "https://www.xdcc.eu/search.php?searchkey=" + search_phrase 

35 response = requests.get(url) 

36 soup = BeautifulSoup(response.text, "html.parser") 

37 entries = soup.select("tr") 

38 entries.pop(0) 

39 

40 packs = [] 

41 for entry in entries: 

42 parts = entry.select("td") 

43 info = parts[1].select("a")[1] 

44 server = IrcServer(info["data-s"]) 

45 pack_message = info["data-p"] 

46 bot, pack_number = pack_message.split(" xdcc send #") 

47 

48 size = byte_string_to_byte_count(parts[5].text) 

49 filename = parts[6].text 

50 

51 pack = XDCCPack(server, bot, int(pack_number)) 

52 pack.set_size(size) 

53 pack.set_filename(filename) 

54 

55 packs.append(pack) 

56 

57 return packs