pars-hitmotop 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,26 @@
1
1
  Metadata-Version: 2.1
2
- Name: pars-hitmotop
3
- Version: 0.1.0
4
- Summary: pars-hitmotop is now pars-hitmos
5
- Classifier: Development Status :: 7 - Inactive
2
+ Name: pars_hitmotop
3
+ Version: 0.1.1
4
+ Home-page: https://github.com/JoyHubN/pars_hitmos
5
+ Download-URL: https://github.com/JoyHubN/pars_hitmos/arhive/v0.1.1.zip
6
+ Author: Joy_079
7
+ Author-email: Prufu@yandex.ru
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3.7
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
6
15
  Description-Content-Type: text/markdown
7
16
 
8
- # pars-hitmontop теперь называется pars-hitmos
9
-
10
- Этот пакет был переименован. Вместо этого используйте `pip install pars-hitmos`.
11
-
12
- Новый пакет: https://pypi.org/project/pars-hitmos/
13
-
14
-
15
17
  # Оглавление
16
- 0. [Оглавление](https://github.com/JoyHubN/pars_hitmos#оглавление)
17
- 1. [Что именно парсит?](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#что-именно-парсит)
18
- 2. [Как использовать модуль entered_tracks](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-entered_tracks)
19
- 3. [Как использовать модуль rating_tracks_count](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-rating_tracks_count)
20
- 4. [Как использовать модуль rating_tracks_page](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-rating_tracks_page)
21
- 5. [Что можно достать при запросе?](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#что-можно-достать-при-запросе)
18
+ 0. [Оглавление](https://github.com/PY079/pars_hitmotop#оглавление)
19
+ 1. [Что именно парсит?](https://github.com/PY079/pars_hitmotop/blob/main/README.md#что-именно-парсит)
20
+ 2. [Как использовать модуль entered_tracks](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-entered_tracks)
21
+ 3. [Как использовать модуль rating_tracks_count](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-rating_tracks_count)
22
+ 4. [Как использовать модуль rating_tracks_page](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-rating_tracks_page)
23
+ 5. [Что можно достать при запросе?](https://github.com/PY079/pars_hitmotop/blob/main/README.md#что-можно-достать-при-запросе)
22
24
  ____
23
25
  Этот проект парсит [музыкальный сайт](https://hitmos.me/)
24
26
  ____
@@ -29,21 +31,21 @@ ____
29
31
  ____
30
32
  ## Как использовать модуль *entered_tracks*
31
33
  ```
32
- from pars_hitmos.entered_tracks import EnteredTrack
34
+ from pars_hitmotop.entered_tracks import EnteredTrack
33
35
  result=EnteredTrack('linkin park',10)
34
36
  ```
35
37
  1 аргументом (music_name) передается название песни или автора. 2 Аргументом (count) передается количество треков
36
38
  ____
37
39
  ## Как использовать модуль *rating_tracks_count*
38
40
  ```
39
- from pars_hitmos.rating_tracks_count import RatingCount
41
+ from pars_hitmotop.rating_tracks_count import RatingCount
40
42
  result=RatingCount(10)
41
43
  ```
42
44
  1 аргументом (count) передается количество песен
43
45
  ____
44
46
  ## Как использовать модуль *rating_tracks_page*
45
47
  ```
46
- from pars_hitmos.rating_tracks_page import RatingPage
48
+ from pars_hitmotop.rating_tracks_page import RatingPage
47
49
  result=RatingPage(10)
48
50
  ```
49
51
  1 аргументом (count) передается количество страниц (max 11)
@@ -1,17 +1,10 @@
1
- # pars-hitmontop теперь называется pars-hitmos
2
-
3
- Этот пакет был переименован. Вместо этого используйте `pip install pars-hitmos`.
4
-
5
- Новый пакет: https://pypi.org/project/pars-hitmos/
6
-
7
-
8
1
  # Оглавление
9
- 0. [Оглавление](https://github.com/JoyHubN/pars_hitmos#оглавление)
10
- 1. [Что именно парсит?](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#что-именно-парсит)
11
- 2. [Как использовать модуль entered_tracks](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-entered_tracks)
12
- 3. [Как использовать модуль rating_tracks_count](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-rating_tracks_count)
13
- 4. [Как использовать модуль rating_tracks_page](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-rating_tracks_page)
14
- 5. [Что можно достать при запросе?](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#что-можно-достать-при-запросе)
2
+ 0. [Оглавление](https://github.com/PY079/pars_hitmotop#оглавление)
3
+ 1. [Что именно парсит?](https://github.com/PY079/pars_hitmotop/blob/main/README.md#что-именно-парсит)
4
+ 2. [Как использовать модуль entered_tracks](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-entered_tracks)
5
+ 3. [Как использовать модуль rating_tracks_count](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-rating_tracks_count)
6
+ 4. [Как использовать модуль rating_tracks_page](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-rating_tracks_page)
7
+ 5. [Что можно достать при запросе?](https://github.com/PY079/pars_hitmotop/blob/main/README.md#что-можно-достать-при-запросе)
15
8
  ____
16
9
  Этот проект парсит [музыкальный сайт](https://hitmos.me/)
17
10
  ____
@@ -22,21 +15,21 @@ ____
22
15
  ____
23
16
  ## Как использовать модуль *entered_tracks*
24
17
  ```
25
- from pars_hitmos.entered_tracks import EnteredTrack
18
+ from pars_hitmotop.entered_tracks import EnteredTrack
26
19
  result=EnteredTrack('linkin park',10)
27
20
  ```
28
21
  1 аргументом (music_name) передается название песни или автора. 2 Аргументом (count) передается количество треков
29
22
  ____
30
23
  ## Как использовать модуль *rating_tracks_count*
31
24
  ```
32
- from pars_hitmos.rating_tracks_count import RatingCount
25
+ from pars_hitmotop.rating_tracks_count import RatingCount
33
26
  result=RatingCount(10)
34
27
  ```
35
28
  1 аргументом (count) передается количество песен
36
29
  ____
37
30
  ## Как использовать модуль *rating_tracks_page*
38
31
  ```
39
- from pars_hitmos.rating_tracks_page import RatingPage
32
+ from pars_hitmotop.rating_tracks_page import RatingPage
40
33
  result=RatingPage(10)
41
34
  ```
42
35
  1 аргументом (count) передается количество страниц (max 11)
@@ -0,0 +1,6 @@
1
+ from .entered_tracks import EnteredTrack
2
+ from .rating_tracks_count import RatingCount
3
+ from .rating_tracks_page import RatingPage
4
+
5
+ __author__ = 'Joy_079'
6
+ __version__= '0.0.5'
@@ -0,0 +1,121 @@
1
+ import fake_useragent, requests
2
+ from bs4 import BeautifulSoup
3
+ from .excepts import NoFoundTrack, MaxTrack, MusicName, AmountErr, RedirectErr
4
+
5
+ class EnteredTrack:
6
+ """
7
+ Треки из запроса\n
8
+ :param music_name: Название и автор трека в одной строке. - str
9
+ :param amount: Количество треков, которое нужно вывести. Max 48. - int
10
+ :param get_redirect_url: bool тип, True-получить прямую ссылку на скачивание трека, но увеличивает время выполнения\n
11
+ Для получения информации доступны след.функции:
12
+ - get_author: list, автор трека;
13
+ - get_title: list, название трека;
14
+ - get_url_down: list, ссылка на скачивание трека;
15
+ - direct_download_link: list прямая ссылка на скачивание трека;
16
+ - get_duration: list, длительность трека;
17
+ - get_picture_url: list, ссылка на обложку трека;
18
+ - get_url_track: list, ссылка на трек.
19
+
20
+ """
21
+
22
+
23
+ def __init__(self, music_name:str, amount: int, get_redirect_url=False):
24
+ if isinstance(music_name, str) is False: raise MusicName
25
+ if isinstance(amount, int) is False: raise AmountErr
26
+ if isinstance(get_redirect_url, bool) is False: raise RedirectErr
27
+
28
+ self.music_name = music_name
29
+ self.amount = int(amount)
30
+ self.get_redirect_url = get_redirect_url
31
+ self.get_info
32
+
33
+
34
+ @property
35
+ def get_info(self):
36
+
37
+ if self.amount > 48:
38
+ raise MaxTrack
39
+ else:
40
+ __user = fake_useragent.UserAgent().random
41
+ __headers = {"user-agent": __user}
42
+ __url11= requests.get('https://hitmos.me/', headers=__headers, allow_redirects=True).url
43
+ __url1= __url11[:-1] if '/' in __url11[:-1] else __url11
44
+
45
+ _url = f"{__url1}{'/' if '/' in __url1[:-1] else ''}search?q={self.music_name}"
46
+
47
+ _response = requests.get(_url, headers=__headers)
48
+ _soup = BeautifulSoup(_response.text, "html.parser")
49
+
50
+
51
+ if _soup.find('h2',class_='tracks__title content-item-title'):
52
+ raise NoFoundTrack
53
+
54
+
55
+
56
+ # получаем информацию о треках
57
+ _track_titles = [i.text.strip() for i in _soup.find_all("div", class_="track__title")]
58
+ _track_artists = [i.text.strip() for i in _soup.find_all("div", class_="track__desc")]
59
+ _track_duration = [i.text.strip() for i in _soup.find_all("div", class_="track__fulltime")]
60
+ _track_pictures = [f"{i.get('style')[23:-3]}" for i in _soup.find_all("div", class_="track__img")]
61
+ _track_urls_dow = [i.get('href') for i in _soup.find_all('a', class_='track__download-btn')]
62
+ _track_url = [f"{__url1}{tra_url.get('href')}" for tra_url in _soup.find_all('a', class_='track__info-l')]
63
+
64
+ _items = []
65
+ for idx in range(self.amount if len(_track_titles) > self.amount else len(_track_titles)):
66
+ if self.get_redirect_url and len(_track_urls_dow[idx])>0:
67
+ direct_download_link = requests.get(_track_urls_dow[idx],headers=__headers,allow_redirects=True).url
68
+ else: direct_download_link = None
69
+
70
+ item = {
71
+ 'author': _track_artists[idx],
72
+ 'title': _track_titles[idx].replace('/','').replace(':','').replace('*','').replace('?','').replace('"','').replace('<','').replace('>','').replace('|','').replace('\\',''),
73
+ 'url_down': _track_urls_dow[idx],
74
+ 'direct_download_link': direct_download_link,
75
+ 'duration_track': _track_duration[idx],
76
+ 'picture_url': _track_pictures[idx],
77
+ 'url_track': _track_url[idx]
78
+ }
79
+ _items.append(item)
80
+
81
+ self.count_tracks = len(_items)
82
+ self.data = {"items": _items}
83
+ return self.data
84
+
85
+ @property
86
+ def get_author(self) -> list[str]:
87
+ return [item['author'] for item in self.data['items']]
88
+
89
+ @property
90
+ def get_title(self) -> list[str]:
91
+ return [item['title'] for item in self.data['items']]
92
+
93
+ @property
94
+ def get_url_down(self) -> list[str]:
95
+ return [item['url_down'] for item in self.data['items']]
96
+
97
+ @property
98
+ def direct_download_link(self) -> list[str]:
99
+ return [item['direct_download_link'] for item in self.data['items']]
100
+
101
+ @property
102
+ def get_duration(self) -> list[str]:
103
+ return [item['duration_track'] for item in self.data['items']]
104
+
105
+ @property
106
+ def get_picture_url(self) -> list[str]:
107
+ return [item['picture_url'] for item in self.data['items']]
108
+
109
+ @property
110
+ def get_url_track(self) -> list[str]:
111
+ return [item['url_track'] for item in self.data['items']]
112
+
113
+ @property
114
+ def get_author_title(self) -> list[str]:
115
+ __author = self.get_author
116
+ __title = self.get_title
117
+ return [f'{__author[i]} - {__title[i]}' for i in range(self.count_tracks)]
118
+
119
+
120
+
121
+
@@ -0,0 +1,67 @@
1
+ class NoFoundTrack(Exception):
2
+
3
+ def __init__(self):
4
+ self.err = 'Nothing was found for your query'
5
+
6
+ def __str__(self):
7
+ return self.err
8
+
9
+ class MaxTrack(Exception):
10
+
11
+ def __init__(self):
12
+ self.err = 'The number of tracks should not exceed 48'
13
+
14
+ def __str__(self):
15
+ return self.err
16
+
17
+
18
+ class PageError(Exception):
19
+
20
+ def __init__(self):
21
+ self.err = 'Only <= 11'
22
+
23
+ def __str__(self):
24
+ return self.err
25
+
26
+
27
+
28
+ class MusicName(Exception):
29
+
30
+ def __init__(self):
31
+ self.err = 'The name of the music should only be str'
32
+
33
+ def __str__(self):
34
+ return self.err
35
+
36
+ class AmountErr(Exception):
37
+
38
+ def __init__(self):
39
+ self.err = 'The amount should only be int'
40
+
41
+ def __str__(self):
42
+ return self.err
43
+
44
+ class PageCount(Exception):
45
+
46
+ def __init__(self):
47
+ self.err = 'Page count only int'
48
+
49
+ def __str__(self):
50
+ return self.err
51
+
52
+
53
+ class CountTracksErr(Exception):
54
+
55
+ def __init__(self):
56
+ self.err = 'The count tracks should only be int'
57
+
58
+ def __str__(self):
59
+ return self.err
60
+
61
+ class RedirectErr(Exception):
62
+
63
+ def __init__(self):
64
+ self.err = 'Accepts only the bool type'
65
+
66
+ def __str__(self):
67
+ return self.err
@@ -0,0 +1,58 @@
1
+ from .entered_tracks import EnteredTrack
2
+ import urllib.request, os
3
+ from colorama import Fore, Style, init
4
+ os.system('cls')
5
+ init()
6
+
7
+ path=r'C:\Users\днс\python_project\pars_hitmotop\music'
8
+ result=EnteredTrack('linkin park',10)
9
+
10
+
11
+ # Получить количество треков
12
+ amout = result.count_tracks
13
+
14
+ # Получить автора треков
15
+ author = result.get_author
16
+
17
+ # Получить названия треков
18
+ title = result.get_title
19
+
20
+ # Получить ссылки на скачивания треков
21
+ url_down= result.get_url_down
22
+
23
+ # Получить прямую ссылку на скачивание треков
24
+ url_down_new= result.direct_download_link
25
+
26
+ # Получить длителькость треков
27
+ duraction = result.get_duraction
28
+
29
+ # Получить обложки треков
30
+ picture = result.get_picture_url
31
+
32
+ # Получить ссылки на треки
33
+ url_tracks = result.get_url_track
34
+
35
+ # Скачать найденные треки треки
36
+ def down_music(path,result):
37
+ for _ in range(result.count_tracks):
38
+ print(f'Скачиваю по ссылке: {result.direct_download_link[_]}')
39
+ if result.direct_download_link[_] != None:
40
+ urllib.request.urlretrieve(result.direct_download_link[_],f"{path}\{result.get_title[_]}.mp3")
41
+ else:
42
+ print(result.get_title[_])
43
+ print(f'Скачиваю hitmotop\n{result.get_url_down[_]}')
44
+ urllib.request.urlretrieve(result.get_url_down[_],f"{path}\{result.get_title[_]}.mp3")
45
+
46
+
47
+ print(f'{Fore.BLUE+Style.BRIGHT}1 запрос {result.music_name}{Style.RESET_ALL}\n')
48
+ for _ in range(result.count_tracks):
49
+ print(f"{author} - {title} {duraction}")
50
+ down_music(path, result)
51
+
52
+
53
+ result = EnteredTrack('green day', 10)
54
+
55
+ print(f'\n\n{Fore.GREEN+Style.BRIGHT}2 запрос {result.music_name}\n\n{Style.RESET_ALL}')
56
+ for _ in range(result.count_tracks):
57
+ print(f"{result.get_author} - {result.get_title} {result.get_duraction}")
58
+ down_music(path, result)
@@ -0,0 +1,104 @@
1
+ '''Рейтинговые треки'''
2
+ import fake_useragent, requests
3
+ from bs4 import BeautifulSoup
4
+ from .excepts import CountTracksErr, RedirectErr
5
+
6
+ class RatingCount:
7
+ '''
8
+ Функция для получения списка рейтинговых треков с сайта hitmos.me.
9
+ param: count - число от 1 до 48, кол-во треков
10
+ \nДля получения информации доступны след.функции:
11
+ - get_author: list, автор трека;
12
+ - get_title: list, название трека;
13
+ - get_url_down: list, ссылка на скачивание трека;
14
+ - direct_download_link: list прямая ссылка на скачивание трека;
15
+ - get_duration: list, длительность трека;
16
+ - get_picture_url: list, ссылка на обложку трека;
17
+ - get_url_track: list, ссылка на трек.
18
+
19
+ '''
20
+
21
+ def __init__(self, count_tracks, get_redirect_url=False):
22
+ if isinstance(count_tracks, int) is False: raise CountTracksErr
23
+ if isinstance(get_redirect_url, bool) is False: raise RedirectErr
24
+
25
+ self.count_tracks = count_tracks
26
+ self.get_redirect_url = get_redirect_url
27
+ self.count_selection
28
+
29
+ @property
30
+ def count_selection(self):
31
+
32
+ if self.count_tracks >48:
33
+ raise ValueError('Only <= 48')
34
+ else:
35
+
36
+ __user = fake_useragent.UserAgent().random
37
+ __headers = {'user-agent': __user}
38
+ __url11= requests.get('https://hitmos.me/', headers=__headers, allow_redirects=True).url
39
+ __url1= __url11[:-1] if '/' in __url11[-1] else __url11
40
+
41
+ url = f"{__url1}{'/' if '/' in __url1[:-1] else ''}songs/top-rated"
42
+
43
+ response = requests.get(url, headers=__headers)
44
+ _soup = BeautifulSoup(response.text, 'html.parser')
45
+
46
+ _track_titles = [i.text.strip() for i in _soup.find_all("div", class_="track__title")]
47
+ _track_artists = [i.text.strip() for i in _soup.find_all("div", class_="track__desc")]
48
+ _track_duration = [i.text.strip() for i in _soup.find_all("div", class_="track__fulltime")]
49
+ _track_pictures = [f"{i.get('style')[23:-3]}" for i in _soup.find_all("div", class_="track__img")]
50
+ _track_urls_dow = [i.get('href') for i in _soup.find_all('a', class_='track__download-btn')]
51
+ _track_url = [f"{__url1}{tra_url.get('href')}" for tra_url in _soup.find_all('a', class_='track__info-l')]
52
+
53
+ _items = []
54
+
55
+ for idx in range(self.count_tracks if len(_track_titles) > self.count_tracks else len(_track_titles)):
56
+ if self.get_redirect_url and len(_track_urls_dow[idx])>0:
57
+ direct_download_link = requests.get(_track_urls_dow[idx],headers=__headers,allow_redirects=True).url
58
+ else: direct_download_link = None
59
+ item = {
60
+ 'author': _track_artists[idx],
61
+ 'title': _track_titles[idx].replace('/','').replace(':','').replace('*','').replace('?','').replace('"','').replace('<','').replace('>','').replace('|','').replace('\\',''),
62
+ 'url_down': _track_urls_dow[idx],
63
+ 'direct_download_link': direct_download_link,
64
+ 'duration_track': _track_duration[idx],
65
+ 'picture_url': _track_pictures[idx],
66
+ 'url_track': _track_url[idx]
67
+ }
68
+ _items.append(item)
69
+
70
+ self.data = {"items": _items}
71
+ return self.data
72
+ @property
73
+ def get_author(self):
74
+ return [item['author'] for item in self.data['items']]
75
+
76
+ @property
77
+ def get_title(self):
78
+ return [item['title'] for item in self.data['items']]
79
+
80
+ @property
81
+ def get_url_down(self):
82
+ return [item['url_down'] for item in self.data['items']]
83
+
84
+ @property
85
+ def direct_download_link(self):
86
+ return [item['direct_download_link'] for item in self.data['items']]
87
+
88
+ @property
89
+ def get_duration(self):
90
+ return [item['duration_track'] for item in self.data['items']]
91
+
92
+ @property
93
+ def get_picture_url(self):
94
+ return [item['picture_url'] for item in self.data['items']]
95
+
96
+ @property
97
+ def get_url_track(self):
98
+ return [item['url_track'] for item in self.data['items']]
99
+
100
+ @property
101
+ def get_author_title(self) -> list[str]:
102
+ __author = self.get_author
103
+ __title = self.get_title
104
+ return [f'{__author[i]} - {__title[i]}' for i in range(self.count_tracks)]
@@ -0,0 +1,150 @@
1
+ '''Рейтинговые треки'''
2
+ import fake_useragent, requests
3
+ from bs4 import BeautifulSoup
4
+ from .excepts import PageError, RedirectErr, PageCount
5
+
6
+ class RatingPage:
7
+ '''
8
+ Функция для получения списка рейтинговых треков с сайта rur.hitmotop.com.
9
+ :param page_count: число от 1 до 11 (номер страницы с треками)
10
+ \nДля получения информации доступны след.функции:
11
+ - get_author: list, автор трека;
12
+ - get_title: list, название трека;
13
+ - get_url_down: list, ссылка на скачивание трека;
14
+ - direct_download_link: list прямая ссылка на скачивание трека;
15
+ - get_duration: list, длительность трека;
16
+ - get_picture_url: list, ссылка на обложку трека;
17
+ - get_url_track: list, ссылка на трек.
18
+ '''
19
+ def __init__(self, page_count:int, get_redirect_url=False):
20
+ if isinstance(page_count, int) is False: raise PageCount
21
+ if isinstance(get_redirect_url, bool) is False: raise RedirectErr
22
+ self.page_count = int(page_count)
23
+ self.get_redirect_url = get_redirect_url
24
+ self.page_selection
25
+
26
+ @property
27
+ def page_selection(self):
28
+
29
+ if self.page_count >11:
30
+ raise PageError
31
+ else:
32
+
33
+ __user = fake_useragent.UserAgent().random
34
+ __headers = {'user-agent': __user}
35
+ __url11= requests.get('https://hitmos.me/', headers=__headers, allow_redirects=True).url
36
+ __url1 = __url11[:-1] if '/' in __url11[-1] else __url11
37
+
38
+ if self.page_count == 1:
39
+ __list = []
40
+ url = f"{__url1}{'/' if '/' in __url1[:-1] else ''}songs/top-rated"
41
+ response = requests.get(url, headers=__headers)
42
+ _soup = BeautifulSoup(response.text, 'html.parser')
43
+
44
+ _track_titles = [i.text.strip() for i in _soup.find_all("div", class_="track__title")]
45
+ _track_artists = [i.text.strip() for i in _soup.find_all("div", class_="track__desc")]
46
+ _track_duration = [i.text.strip() for i in _soup.find_all("div", class_="track__fulltime")]
47
+ _track_pictures = [f"{i.get('style')[23:-3]}" for i in _soup.find_all("div", class_="track__img")]
48
+ _track_urls_dow = [i.get('href') for i in _soup.find_all('a', class_='track__download-btn')]
49
+ _track_url = [f"{__url1}{tra_url.get('href')}" for tra_url in _soup.find_all('a', class_='track__info-l')]
50
+
51
+ for idx in range(len(_track_titles), 48):
52
+ if self.get_redirect_url and len(_track_urls_dow[idx])>0:
53
+ direct_download_link = requests.get(_track_urls_dow[idx],headers=__headers,allow_redirects=True).url
54
+ else: direct_download_link = None
55
+
56
+ items={
57
+ 'author': _track_artists[idx],
58
+ 'title': _track_titles[idx].replace('/','').replace(':','').replace('*','').replace('?','').replace('"','').replace('<','').replace('>','').replace('|','').replace('\\',''),
59
+ 'url_down': _track_urls_dow[idx],
60
+ 'direct_download_link': direct_download_link,
61
+ 'url_track': _track_url[idx],
62
+ 'duration_track': _track_duration[idx],
63
+ 'picture_url': _track_pictures[idx]
64
+ }
65
+ __list.append(items)
66
+
67
+ self.count_tracks = len(__list)
68
+ self.data = {'items': __list}
69
+ return self.data
70
+
71
+
72
+ else:
73
+ self.page_count *= 48
74
+
75
+ __list = []
76
+
77
+ url = f"{__url1}{'/' if '/' in __url1[:-1] else ''}songs/top-rated/start/"
78
+
79
+ items = []
80
+ for page in range(0, self.page_count, 48):
81
+
82
+ response = requests.get(f'{url}{page}', headers=__headers)
83
+ soup = BeautifulSoup(response.text, 'lxml')
84
+
85
+
86
+ track_titles = [i.text.strip() for i in soup.find_all("div", class_="track__title")]
87
+ track_artists = [i.text.strip() for i in soup.find_all("div", class_="track__desc")]
88
+ track_duration = [i.text.strip() for i in soup.find_all("div", class_="track__fulltime")]
89
+ track_pictures = [f"{__url1}{i.get('style')[23:-3]}" for i in soup.find_all("div", class_="track__img")]
90
+ track_urls_dow = [f"{track_dow_url.get('href')}" for track_dow_url in soup.find_all('a', class_='track__download-btn')]
91
+ track_url = [f"{__url1}{tra_url.get('href')}" for tra_url in soup.find_all('a', class_='track__info-l')]
92
+
93
+
94
+ for idx in range(min(len(track_titles), 48)):
95
+ if self.get_redirect_url and len(_track_urls_dow[idx])>0:
96
+ direct_download_link = requests.get(_track_urls_dow[idx],headers=__headers,allow_redirects=True).url
97
+ else: direct_download_link=None
98
+
99
+ items={
100
+ 'author': track_artists[idx],
101
+ 'title': track_titles[idx],
102
+ 'url_down': track_urls_dow[idx],
103
+ 'direct_download_link': direct_download_link,
104
+ 'url_track': track_url[idx],
105
+ 'duration_track': track_duration[idx],
106
+ 'picture_url': track_pictures[idx]
107
+ }
108
+ __list.append(items)
109
+ self.count_tracks = len(__list)
110
+ self.data = {'items': __list}
111
+ return self.data
112
+
113
+ @property
114
+ def get_author(self):
115
+ return [item['author'] for item in self.data['items']]
116
+
117
+ @property
118
+ def get_title(self):
119
+ return [item['title'] for item in self.data['items']]
120
+
121
+ @property
122
+ def get_url_down(self):
123
+ return [item['url_down'] for item in self.data['items']]
124
+
125
+ @property
126
+ def direct_download_link(self):
127
+ return [item['direct_download_link'] for item in self.data['items']]
128
+
129
+ @property
130
+ def get_duration(self):
131
+ return [item['duration_track'] for item in self.data['items']]
132
+
133
+ @property
134
+ def get_picture_url(self):
135
+ return [item['picture_url'] for item in self.data['items']]
136
+
137
+ @property
138
+ def get_url_track(self):
139
+ return [item['url_track'] for item in self.data['items']]
140
+
141
+ @property
142
+ def get_all(self): return self.data
143
+
144
+ @property
145
+ def get_author_title(self) -> list[str]:
146
+ __author = self.get_author
147
+ __title = self.get_title
148
+ return [f'{__author[i]} - {__title[i]}' for i in range(self.count_tracks)]
149
+
150
+
@@ -1,24 +1,26 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pars-hitmotop
3
- Version: 0.1.0
4
- Summary: pars-hitmotop is now pars-hitmos
5
- Classifier: Development Status :: 7 - Inactive
3
+ Version: 0.1.1
4
+ Home-page: https://github.com/JoyHubN/pars_hitmos
5
+ Download-URL: https://github.com/JoyHubN/pars_hitmos/arhive/v0.1.1.zip
6
+ Author: Joy_079
7
+ Author-email: Prufu@yandex.ru
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3.7
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
6
15
  Description-Content-Type: text/markdown
7
16
 
8
- # pars-hitmontop теперь называется pars-hitmos
9
-
10
- Этот пакет был переименован. Вместо этого используйте `pip install pars-hitmos`.
11
-
12
- Новый пакет: https://pypi.org/project/pars-hitmos/
13
-
14
-
15
17
  # Оглавление
16
- 0. [Оглавление](https://github.com/JoyHubN/pars_hitmos#оглавление)
17
- 1. [Что именно парсит?](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#что-именно-парсит)
18
- 2. [Как использовать модуль entered_tracks](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-entered_tracks)
19
- 3. [Как использовать модуль rating_tracks_count](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-rating_tracks_count)
20
- 4. [Как использовать модуль rating_tracks_page](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#как-использовать-модуль-rating_tracks_page)
21
- 5. [Что можно достать при запросе?](https://github.com/JoyHubN/pars_hitmos/blob/main/README.md#что-можно-достать-при-запросе)
18
+ 0. [Оглавление](https://github.com/PY079/pars_hitmotop#оглавление)
19
+ 1. [Что именно парсит?](https://github.com/PY079/pars_hitmotop/blob/main/README.md#что-именно-парсит)
20
+ 2. [Как использовать модуль entered_tracks](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-entered_tracks)
21
+ 3. [Как использовать модуль rating_tracks_count](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-rating_tracks_count)
22
+ 4. [Как использовать модуль rating_tracks_page](https://github.com/PY079/pars_hitmotop/blob/main/README.md#как-использовать-модуль-rating_tracks_page)
23
+ 5. [Что можно достать при запросе?](https://github.com/PY079/pars_hitmotop/blob/main/README.md#что-можно-достать-при-запросе)
22
24
  ____
23
25
  Этот проект парсит [музыкальный сайт](https://hitmos.me/)
24
26
  ____
@@ -29,21 +31,21 @@ ____
29
31
  ____
30
32
  ## Как использовать модуль *entered_tracks*
31
33
  ```
32
- from pars_hitmos.entered_tracks import EnteredTrack
34
+ from pars_hitmotop.entered_tracks import EnteredTrack
33
35
  result=EnteredTrack('linkin park',10)
34
36
  ```
35
37
  1 аргументом (music_name) передается название песни или автора. 2 Аргументом (count) передается количество треков
36
38
  ____
37
39
  ## Как использовать модуль *rating_tracks_count*
38
40
  ```
39
- from pars_hitmos.rating_tracks_count import RatingCount
41
+ from pars_hitmotop.rating_tracks_count import RatingCount
40
42
  result=RatingCount(10)
41
43
  ```
42
44
  1 аргументом (count) передается количество песен
43
45
  ____
44
46
  ## Как использовать модуль *rating_tracks_page*
45
47
  ```
46
- from pars_hitmos.rating_tracks_page import RatingPage
48
+ from pars_hitmotop.rating_tracks_page import RatingPage
47
49
  result=RatingPage(10)
48
50
  ```
49
51
  1 аргументом (count) передается количество страниц (max 11)
@@ -0,0 +1,13 @@
1
+ README.md
2
+ setup.py
3
+ pars_hitmotop/__init__.py
4
+ pars_hitmotop/entered_tracks.py
5
+ pars_hitmotop/excepts.py
6
+ pars_hitmotop/how_to_use.py
7
+ pars_hitmotop/rating_tracks_count.py
8
+ pars_hitmotop/rating_tracks_page.py
9
+ pars_hitmotop.egg-info/PKG-INFO
10
+ pars_hitmotop.egg-info/SOURCES.txt
11
+ pars_hitmotop.egg-info/dependency_links.txt
12
+ pars_hitmotop.egg-info/requires.txt
13
+ pars_hitmotop.egg-info/top_level.txt
@@ -0,0 +1,5 @@
1
+ bs4
2
+ colorama
3
+ fake-useragent
4
+ requests
5
+ lxml
@@ -0,0 +1 @@
1
+ pars_hitmotop
@@ -0,0 +1,29 @@
1
+ from setuptools import setup
2
+
3
+ version='0.1.1'
4
+ with open('README.md', encoding='utf-8') as f:
5
+ long_description=f.read()
6
+
7
+ setup(
8
+ name='pars_hitmotop',
9
+ version=version,
10
+
11
+ author='Joy_079',
12
+ author_email='Prufu@yandex.ru',
13
+ long_description=long_description,
14
+ long_description_content_type='text/markdown',
15
+ url='https://github.com/JoyHubN/pars_hitmos',
16
+ download_url=f'https://github.com/JoyHubN/pars_hitmos/arhive/v{version}.zip',
17
+ install_requires=['bs4','colorama','fake-useragent','requests','lxml'],
18
+ # license=...,
19
+ packages=['pars_hitmotop'],
20
+ classifiers=[
21
+ 'Programming Language :: Python',
22
+ 'Programming Language :: Python :: 3.7',
23
+ 'Programming Language :: Python :: 3.8',
24
+ 'Programming Language :: Python :: 3.9',
25
+ 'Programming Language :: Python :: 3.10',
26
+ 'Programming Language :: Python :: 3.11',
27
+ 'Programming Language :: Python :: Implementation :: PyPy'
28
+ ]
29
+ )
@@ -1,7 +0,0 @@
1
- README.md
2
- setup.py
3
- pars_hitmotop.egg-info/PKG-INFO
4
- pars_hitmotop.egg-info/SOURCES.txt
5
- pars_hitmotop.egg-info/dependency_links.txt
6
- pars_hitmotop.egg-info/requires.txt
7
- pars_hitmotop.egg-info/top_level.txt
@@ -1 +0,0 @@
1
- pars-hitmos
@@ -1,23 +0,0 @@
1
- from setuptools import setup
2
- import os
3
-
4
- VERSION = "0.1.0"
5
-
6
-
7
- def get_long_description():
8
- with open(
9
- os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md"),
10
- encoding="utf8",
11
- ) as fp:
12
- return fp.read()
13
-
14
-
15
- setup(
16
- name="pars-hitmotop",
17
- description="pars-hitmotop is now pars-hitmos",
18
- long_description=get_long_description(),
19
- long_description_content_type="text/markdown",
20
- version=VERSION,
21
- install_requires=["pars-hitmos"],
22
- classifiers=["Development Status :: 7 - Inactive"],
23
- )
File without changes