feat: added correct referers
This commit is contained in:
		| @@ -5,48 +5,10 @@ print("Setting logging-level to DEBUG") | |||||||
| logging.getLogger().setLevel(logging.DEBUG) | logging.getLogger().setLevel(logging.DEBUG) | ||||||
|  |  | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     normally_download = [ |  | ||||||
|         "s: #a Favorite #r Anarcho", |  | ||||||
|         "1", |  | ||||||
|         "d: 1, 5" |  | ||||||
|     ] |  | ||||||
|  |  | ||||||
|     direct_download = [ |  | ||||||
|         "d: https://musify.club/release/crystal-f-x-2012-795181" |  | ||||||
|     ] |  | ||||||
|      |  | ||||||
|     fetch_musify_song = [ |  | ||||||
|         "s: https://musify.club/track/blokkmonsta-schwartz-crystal-f-purer-hass-8369115" |  | ||||||
|     ] |  | ||||||
|  |  | ||||||
|     fetch_youtube_playlist = [ |  | ||||||
|         "s: https://yt.artemislena.eu/playlist?list=OLAK5uy_kcUBiDv5ATbl-R20OjNaZ5G28XFanQOmM" |  | ||||||
|     ] |  | ||||||
|  |  | ||||||
|     download_youtube_playlist = ["d: https://www.youtube.com/playlist?list=OLAK5uy_lqI_c6aDF9q4DWJ4TBzt1AFQYx_FXfU4E"] |  | ||||||
|      |  | ||||||
|     youtube_search = [ |  | ||||||
|         "s: #a Zombiez", |  | ||||||
|         "10", |  | ||||||
|         "d: 5" |  | ||||||
|     ] |  | ||||||
|  |  | ||||||
|     youtube_music_test = [ |  | ||||||
|         "s: #a Only Smile #r Your best friend", |  | ||||||
|         "8", |  | ||||||
|         "2", |  | ||||||
|         "d: 2" |  | ||||||
|     ] |  | ||||||
|  |  | ||||||
|     cross_download = [ |  | ||||||
|         "s: #a Psychonaut 4", |  | ||||||
|         "2", |  | ||||||
|         "d: 0" |  | ||||||
|     ] |  | ||||||
|  |  | ||||||
|     commands = [ |     commands = [ | ||||||
|         "s: #a PTK", |         "s: #a PTK", | ||||||
|         "d: 26", |         "26", | ||||||
|  |         "d: 1", | ||||||
|     ] |     ] | ||||||
|  |  | ||||||
|      |      | ||||||
|   | |||||||
| @@ -24,8 +24,7 @@ class CacheAttribute: | |||||||
|     @property |     @property | ||||||
|     def is_valid(self): |     def is_valid(self): | ||||||
|         if isinstance(self.expires, str): |         if isinstance(self.expires, str): | ||||||
|             pass |             self.expires = datetime.fromisoformat(self.expires) | ||||||
|             # self.expires = datetime.fromisoformat(self.expires) |  | ||||||
|         return datetime.now() < self.expires |         return datetime.now() < self.expires | ||||||
|  |  | ||||||
|     def __eq__(self, other): |     def __eq__(self, other): | ||||||
|   | |||||||
| @@ -38,13 +38,11 @@ class Connection: | |||||||
|     ): |     ): | ||||||
|         if proxies is None: |         if proxies is None: | ||||||
|             proxies = main_settings["proxies"] |             proxies = main_settings["proxies"] | ||||||
|         if header_values is None: |  | ||||||
|             header_values = dict() |  | ||||||
|  |  | ||||||
|         self.cache: Cache = Cache(module=module, logger=logger) |         self.cache: Cache = Cache(module=module, logger=logger) | ||||||
|         self.cache_expiring_duration = cache_expiring_duration |         self.cache_expiring_duration = cache_expiring_duration | ||||||
|  |  | ||||||
|         self.HEADER_VALUES = header_values |         self.HEADER_VALUES = dict() if header_values is None else header_values | ||||||
|  |  | ||||||
|         self.LOGGER = logger |         self.LOGGER = logger | ||||||
|         self.HOST = urlparse(host) |         self.HOST = urlparse(host) | ||||||
| @@ -151,10 +149,16 @@ class Connection: | |||||||
|         accepted_response_codes = self.ACCEPTED_RESPONSE_CODES if accepted_response_codes is None else accepted_response_codes |         accepted_response_codes = self.ACCEPTED_RESPONSE_CODES if accepted_response_codes is None else accepted_response_codes | ||||||
|          |          | ||||||
|         current_kwargs = copy.copy(locals()) |         current_kwargs = copy.copy(locals()) | ||||||
|  |         current_kwargs.pop("kwargs") | ||||||
|  |         current_kwargs.update(**kwargs) | ||||||
|  |  | ||||||
|  |  | ||||||
|         parsed_url = urlparse(url) |         parsed_url = urlparse(url) | ||||||
|  |         _headers = copy.copy(self.HEADER_VALUES) | ||||||
|  |         _headers.update(headers) | ||||||
|  |  | ||||||
|         headers = self._update_headers( |         headers = self._update_headers( | ||||||
|             headers=headers, |             headers=_headers, | ||||||
|             refer_from_origin=refer_from_origin, |             refer_from_origin=refer_from_origin, | ||||||
|             url=parsed_url |             url=parsed_url | ||||||
|         ) |         ) | ||||||
| @@ -318,6 +322,6 @@ class Connection: | |||||||
|             if retry: |             if retry: | ||||||
|                 self.LOGGER.warning(f"Retrying stream...") |                 self.LOGGER.warning(f"Retrying stream...") | ||||||
|                 accepted_response_codes.add(206) |                 accepted_response_codes.add(206) | ||||||
|                 return self.stream_into(**stream_kwargs) |                 return Connection.stream_into(**stream_kwargs) | ||||||
|  |  | ||||||
|             return DownloadResult() |             return DownloadResult() | ||||||
|   | |||||||
| @@ -189,7 +189,11 @@ class YoutubeMusic(SuperYouTube): | |||||||
|         self.download_connection: Connection = Connection( |         self.download_connection: Connection = Connection( | ||||||
|             host="https://rr2---sn-cxaf0x-nugl.googlevideo.com/", |             host="https://rr2---sn-cxaf0x-nugl.googlevideo.com/", | ||||||
|             logger=self.LOGGER, |             logger=self.LOGGER, | ||||||
|             sleep_after_404=youtube_settings["sleep_after_youtube_403"] |             sleep_after_404=youtube_settings["sleep_after_youtube_403"], | ||||||
|  |             header_values={ | ||||||
|  |                 "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8", | ||||||
|  |                 "Referer": "https://music.youtube.com/", | ||||||
|  |             } | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         # https://github.com/ytdl-org/youtube-dl/blob/master/README.md#embedding-youtube-dl |         # https://github.com/ytdl-org/youtube-dl/blob/master/README.md#embedding-youtube-dl | ||||||
| @@ -507,7 +511,6 @@ class YoutubeMusic(SuperYouTube): | |||||||
|         return song |         return song | ||||||
|  |  | ||||||
|     def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult: |     def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult: | ||||||
|         if source.audio_url is None: |  | ||||||
|         self.fetch_song(source) |         self.fetch_song(source) | ||||||
|  |  | ||||||
|         if source.audio_url is None: |         if source.audio_url is None: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user