pars-hitmotop 0.0.9__tar.gz → 0.1.0__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,26 +1,24 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pars-hitmotop
3
- Version: 0.0.9
4
- Home-page: https://github.com/PY079/pars_hitmotop
5
- Download-URL: https://github.com/PY079/pars_hitmotop/arhive/v0.0.9.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
3
+ Version: 0.1.0
4
+ Summary: pars-hitmotop is now pars-hitmos
5
+ Classifier: Development Status :: 7 - Inactive
15
6
  Description-Content-Type: text/markdown
16
7
 
8
+ # pars-hitmontop теперь называется pars-hitmos
9
+
10
+ Этот пакет был переименован. Вместо этого используйте `pip install pars-hitmos`.
11
+
12
+ Новый пакет: https://pypi.org/project/pars-hitmos/
13
+
14
+
17
15
  # Оглавление
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#что-можно-достать-при-запросе)
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#что-можно-достать-при-запросе)
24
22
  ____
25
23
  Этот проект парсит [музыкальный сайт](https://hitmos.me/)
26
24
  ____
@@ -31,21 +29,21 @@ ____
31
29
  ____
32
30
  ## Как использовать модуль *entered_tracks*
33
31
  ```
34
- from pars_hitmotop.entered_tracks import EnteredTrack
32
+ from pars_hitmos.entered_tracks import EnteredTrack
35
33
  result=EnteredTrack('linkin park',10)
36
34
  ```
37
35
  1 аргументом (music_name) передается название песни или автора. 2 Аргументом (count) передается количество треков
38
36
  ____
39
37
  ## Как использовать модуль *rating_tracks_count*
40
38
  ```
41
- from pars_hitmotop.rating_tracks_count import RatingCount
39
+ from pars_hitmos.rating_tracks_count import RatingCount
42
40
  result=RatingCount(10)
43
41
  ```
44
42
  1 аргументом (count) передается количество песен
45
43
  ____
46
44
  ## Как использовать модуль *rating_tracks_page*
47
45
  ```
48
- from pars_hitmotop.rating_tracks_page import RatingPage
46
+ from pars_hitmos.rating_tracks_page import RatingPage
49
47
  result=RatingPage(10)
50
48
  ```
51
49
  1 аргументом (count) передается количество страниц (max 11)
@@ -1,10 +1,17 @@
1
+ # pars-hitmontop теперь называется pars-hitmos
2
+
3
+ Этот пакет был переименован. Вместо этого используйте `pip install pars-hitmos`.
4
+
5
+ Новый пакет: https://pypi.org/project/pars-hitmos/
6
+
7
+
1
8
  # Оглавление
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#что-можно-достать-при-запросе)
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#что-можно-достать-при-запросе)
8
15
  ____
9
16
  Этот проект парсит [музыкальный сайт](https://hitmos.me/)
10
17
  ____
@@ -15,21 +22,21 @@ ____
15
22
  ____
16
23
  ## Как использовать модуль *entered_tracks*
17
24
  ```
18
- from pars_hitmotop.entered_tracks import EnteredTrack
25
+ from pars_hitmos.entered_tracks import EnteredTrack
19
26
  result=EnteredTrack('linkin park',10)
20
27
  ```
21
28
  1 аргументом (music_name) передается название песни или автора. 2 Аргументом (count) передается количество треков
22
29
  ____
23
30
  ## Как использовать модуль *rating_tracks_count*
24
31
  ```
25
- from pars_hitmotop.rating_tracks_count import RatingCount
32
+ from pars_hitmos.rating_tracks_count import RatingCount
26
33
  result=RatingCount(10)
27
34
  ```
28
35
  1 аргументом (count) передается количество песен
29
36
  ____
30
37
  ## Как использовать модуль *rating_tracks_page*
31
38
  ```
32
- from pars_hitmotop.rating_tracks_page import RatingPage
39
+ from pars_hitmos.rating_tracks_page import RatingPage
33
40
  result=RatingPage(10)
34
41
  ```
35
42
  1 аргументом (count) передается количество страниц (max 11)
@@ -1,26 +1,24 @@
1
1
  Metadata-Version: 2.1
2
- Name: pars_hitmotop
3
- Version: 0.0.9
4
- Home-page: https://github.com/PY079/pars_hitmotop
5
- Download-URL: https://github.com/PY079/pars_hitmotop/arhive/v0.0.9.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
2
+ Name: pars-hitmotop
3
+ Version: 0.1.0
4
+ Summary: pars-hitmotop is now pars-hitmos
5
+ Classifier: Development Status :: 7 - Inactive
15
6
  Description-Content-Type: text/markdown
16
7
 
8
+ # pars-hitmontop теперь называется pars-hitmos
9
+
10
+ Этот пакет был переименован. Вместо этого используйте `pip install pars-hitmos`.
11
+
12
+ Новый пакет: https://pypi.org/project/pars-hitmos/
13
+
14
+
17
15
  # Оглавление
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#что-можно-достать-при-запросе)
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#что-можно-достать-при-запросе)
24
22
  ____
25
23
  Этот проект парсит [музыкальный сайт](https://hitmos.me/)
26
24
  ____
@@ -31,21 +29,21 @@ ____
31
29
  ____
32
30
  ## Как использовать модуль *entered_tracks*
33
31
  ```
34
- from pars_hitmotop.entered_tracks import EnteredTrack
32
+ from pars_hitmos.entered_tracks import EnteredTrack
35
33
  result=EnteredTrack('linkin park',10)
36
34
  ```
37
35
  1 аргументом (music_name) передается название песни или автора. 2 Аргументом (count) передается количество треков
38
36
  ____
39
37
  ## Как использовать модуль *rating_tracks_count*
40
38
  ```
41
- from pars_hitmotop.rating_tracks_count import RatingCount
39
+ from pars_hitmos.rating_tracks_count import RatingCount
42
40
  result=RatingCount(10)
43
41
  ```
44
42
  1 аргументом (count) передается количество песен
45
43
  ____
46
44
  ## Как использовать модуль *rating_tracks_page*
47
45
  ```
48
- from pars_hitmotop.rating_tracks_page import RatingPage
46
+ from pars_hitmos.rating_tracks_page import RatingPage
49
47
  result=RatingPage(10)
50
48
  ```
51
49
  1 аргументом (count) передается количество страниц (max 11)
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
1
+ pars-hitmos
@@ -0,0 +1,23 @@
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
+ )
@@ -1,6 +0,0 @@
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'
@@ -1,121 +0,0 @@
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(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
-
@@ -1,67 +0,0 @@
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
@@ -1,58 +0,0 @@
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)
@@ -1,104 +0,0 @@
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(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)]
@@ -1,151 +0,0 @@
1
- '''Рейтинговые треки'''
2
- import fake_useragent, requests
3
- from bs4 import BeautifulSoup
4
- from typing import Union
5
- from .excepts import PageError, RedirectErr, PageCount
6
-
7
- class RatingPage:
8
- '''
9
- Функция для получения списка рейтинговых треков с сайта rur.hitmotop.com.
10
- :param page_count: число от 1 до 11 (номер страницы с треками)
11
- \nДля получения информации доступны след.функции:
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
- def __init__(self, page_count:int, get_redirect_url=False):
21
- if isinstance(page_count, int) is False: raise PageCount
22
- if isinstance(get_redirect_url, bool) is False: raise RedirectErr
23
- self.page_count = int(page_count)
24
- self.get_redirect_url = get_redirect_url
25
- self.page_selection
26
-
27
- @property
28
- def page_selection(self):
29
-
30
- if self.page_count >11:
31
- raise PageError
32
- else:
33
-
34
- __user = fake_useragent.UserAgent().random
35
- __headers = {'user-agent': __user}
36
- __url11= requests.get('https://hitmos.me/', headers=__headers, allow_redirects=True).url
37
- __url1 = __url11[:-1] if '/' in __url11[-1] else __url11
38
-
39
- if self.page_count == 1:
40
- __list = []
41
- url = f"{__url1}{'/' if '/' in __url1[:-1] else ''}songs/top-rated"
42
- response = requests.get(url, headers=__headers)
43
- _soup = BeautifulSoup(response.text, 'html.parser')
44
-
45
- _track_titles = [i.text.strip() for i in _soup.find_all("div", class_="track__title")]
46
- _track_artists = [i.text.strip() for i in _soup.find_all("div", class_="track__desc")]
47
- _track_duration = [i.text.strip() for i in _soup.find_all("div", class_="track__fulltime")]
48
- _track_pictures = [f"{i.get('style')[23:-3]}" for i in _soup.find_all("div", class_="track__img")]
49
- _track_urls_dow = [i.get('href') for i in _soup.find_all('a', class_='track__download-btn')]
50
- _track_url = [f"{__url1}{tra_url.get('href')}" for tra_url in _soup.find_all('a', class_='track__info-l')]
51
-
52
- for idx in range(min(len(_track_titles), 48)):
53
- if self.get_redirect_url and len(_track_urls_dow[idx])>0:
54
- direct_download_link = requests.get(_track_urls_dow[idx],headers=__headers,allow_redirects=True).url
55
- else: direct_download_link = None
56
-
57
- items={
58
- 'author': _track_artists[idx],
59
- 'title': _track_titles[idx].replace('/','').replace(':','').replace('*','').replace('?','').replace('"','').replace('<','').replace('>','').replace('|','').replace('\\',''),
60
- 'url_down': _track_urls_dow[idx],
61
- 'direct_download_link': direct_download_link,
62
- 'url_track': _track_url[idx],
63
- 'duration_track': _track_duration[idx],
64
- 'picture_url': _track_pictures[idx]
65
- }
66
- __list.append(items)
67
-
68
- self.count_tracks = len(__list)
69
- self.data = {'items': __list}
70
- return self.data
71
-
72
-
73
- else:
74
- self.page_count *= 48
75
-
76
- __list = []
77
-
78
- url = f"{__url1}{'/' if '/' in __url1[:-1] else ''}songs/top-rated/start/"
79
-
80
- items = []
81
- for page in range(0, self.page_count, 48):
82
-
83
- response = requests.get(f'{url}{page}', headers=__headers)
84
- soup = BeautifulSoup(response.text, 'lxml')
85
-
86
-
87
- track_titles = [i.text.strip() for i in soup.find_all("div", class_="track__title")]
88
- track_artists = [i.text.strip() for i in soup.find_all("div", class_="track__desc")]
89
- track_duration = [i.text.strip() for i in soup.find_all("div", class_="track__fulltime")]
90
- track_pictures = [f"{__url1}{i.get('style')[23:-3]}" for i in soup.find_all("div", class_="track__img")]
91
- track_urls_dow = [f"{track_dow_url.get('href')}" for track_dow_url in soup.find_all('a', class_='track__download-btn')]
92
- track_url = [f"{__url1}{tra_url.get('href')}" for tra_url in soup.find_all('a', class_='track__info-l')]
93
-
94
-
95
- for idx in range(min(len(track_titles), 48)):
96
- if self.get_redirect_url and len(_track_urls_dow[idx])>0:
97
- direct_download_link = requests.get(_track_urls_dow[idx],headers=__headers,allow_redirects=True).url
98
- else: direct_download_link=None
99
-
100
- items={
101
- 'author': track_artists[idx],
102
- 'title': track_titles[idx],
103
- 'url_down': track_urls_dow[idx],
104
- 'direct_download_link': direct_download_link,
105
- 'url_track': track_url[idx],
106
- 'duration_track': track_duration[idx],
107
- 'picture_url': track_pictures[idx]
108
- }
109
- __list.append(items)
110
- self.count_tracks = len(__list)
111
- self.data = {'items': __list}
112
- return self.data
113
-
114
- @property
115
- def get_author(self):
116
- return [item['author'] for item in self.data['items']]
117
-
118
- @property
119
- def get_title(self):
120
- return [item['title'] for item in self.data['items']]
121
-
122
- @property
123
- def get_url_down(self):
124
- return [item['url_down'] for item in self.data['items']]
125
-
126
- @property
127
- def direct_download_link(self):
128
- return [item['direct_download_link'] for item in self.data['items']]
129
-
130
- @property
131
- def get_duration(self):
132
- return [item['duration_track'] for item in self.data['items']]
133
-
134
- @property
135
- def get_picture_url(self):
136
- return [item['picture_url'] for item in self.data['items']]
137
-
138
- @property
139
- def get_url_track(self):
140
- return [item['url_track'] for item in self.data['items']]
141
-
142
- @property
143
- def get_all(self): return self.data
144
-
145
- @property
146
- def get_author_title(self) -> list[str]:
147
- __author = self.get_author
148
- __title = self.get_title
149
- return [f'{__author[i]} - {__title[i]}' for i in range(self.count_tracks)]
150
-
151
-
@@ -1,13 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- bs4
2
- colorama
3
- fake-useragent
4
- requests
5
- lxml
@@ -1 +0,0 @@
1
- pars_hitmotop
@@ -1,29 +0,0 @@
1
- from setuptools import setup
2
-
3
- version='0.0.9'
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/PY079/pars_hitmotop',
16
- download_url=f'https://github.com/PY079/pars_hitmotop/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
- )
File without changes