Spaces:
Paused
Paused
Update ccc.py
Browse files
ccc.py
CHANGED
|
@@ -1,52 +1,71 @@
|
|
| 1 |
-
|
| 2 |
import requests
|
| 3 |
import random
|
| 4 |
-
import string
|
| 5 |
from bs4 import BeautifulSoup
|
| 6 |
import os
|
| 7 |
|
| 8 |
WEBHOOK_URL = os.environ['web']
|
| 9 |
-
BASE_URL = "https://
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
def
|
| 13 |
-
return ''.join(random.choices(string.ascii_letters, k=length))
|
| 14 |
-
|
| 15 |
-
def send_webhook_message(video_link):
|
| 16 |
data = {
|
| 17 |
-
"content":
|
| 18 |
}
|
| 19 |
response = requests.post(WEBHOOK_URL, json=data)
|
| 20 |
-
|
| 21 |
if response.status_code != 204:
|
| 22 |
-
|
| 23 |
|
| 24 |
-
def
|
| 25 |
try:
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
if response.status_code == 200:
|
| 28 |
soup = BeautifulSoup(response.content, 'html.parser')
|
| 29 |
-
|
| 30 |
-
if
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
def main():
|
|
|
|
|
|
|
| 37 |
while True:
|
| 38 |
try:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
else:
|
| 45 |
-
print(f"
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
-
print(f"
|
|
|
|
|
|
|
| 50 |
|
| 51 |
if __name__ == "__main__":
|
| 52 |
-
main()
|
|
|
|
| 1 |
+
import time
|
| 2 |
import requests
|
| 3 |
import random
|
|
|
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
import os
|
| 6 |
|
| 7 |
WEBHOOK_URL = os.environ['web']
|
| 8 |
+
BASE_URL = "https://tidal.com/browse/track/"
|
| 9 |
+
TRACK_CHECK_INTERVAL = 1
|
| 10 |
+
START_TRACK_ID = 0
|
| 11 |
|
| 12 |
+
def send_webhook_message(track_link, track_info):
|
|
|
|
|
|
|
|
|
|
| 13 |
data = {
|
| 14 |
+
"content": f"{track_link}\n{track_info}"
|
| 15 |
}
|
| 16 |
response = requests.post(WEBHOOK_URL, json=data)
|
| 17 |
+
|
| 18 |
if response.status_code != 204:
|
| 19 |
+
print(f"Fss: {response.status_code}")
|
| 20 |
|
| 21 |
+
def check_tidal_track(track_id):
|
| 22 |
try:
|
| 23 |
+
url = f"{BASE_URL}{track_id}"
|
| 24 |
+
headers = {
|
| 25 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
| 26 |
+
}
|
| 27 |
+
response = requests.get(url, headers=headers)
|
| 28 |
+
|
| 29 |
if response.status_code == 200:
|
| 30 |
soup = BeautifulSoup(response.content, 'html.parser')
|
| 31 |
+
|
| 32 |
+
# Check if track exists by looking for the title
|
| 33 |
+
title_element = soup.find('h1', class_="font-size-regular mt-0 mb-0 ellipsis-double overflow-hidden")
|
| 34 |
+
|
| 35 |
+
if title_element:
|
| 36 |
+
# Try to find artist information
|
| 37 |
+
artist_element = soup.find('a', class_="artist-link")
|
| 38 |
+
artist_name = artist_element.text if artist_element else "Unknown Artist"
|
| 39 |
+
|
| 40 |
+
track_info = f"{title_element.text}\n{artist_name}"
|
| 41 |
+
return True, track_info
|
| 42 |
+
|
| 43 |
+
return False, None
|
| 44 |
+
except Exception as e:
|
| 45 |
+
print(f"Error checking track {track_id}: {e}")
|
| 46 |
+
return False, None
|
| 47 |
|
| 48 |
def main():
|
| 49 |
+
current_track_id = START_TRACK_ID
|
| 50 |
+
|
| 51 |
while True:
|
| 52 |
try:
|
| 53 |
+
track_exists, track_info = check_tidal_track(current_track_id)
|
| 54 |
+
|
| 55 |
+
if track_exists:
|
| 56 |
+
track_link = f"{BASE_URL}{current_track_id}"
|
| 57 |
+
print(f"Found valid track: {track_link} - {track_info}")
|
| 58 |
+
send_webhook_message(track_link, track_info)
|
| 59 |
else:
|
| 60 |
+
print(f"Track {current_track_id} does not exist")
|
| 61 |
+
|
| 62 |
+
current_track_id += 1
|
| 63 |
+
time.sleep(TRACK_CHECK_INTERVAL)
|
| 64 |
+
|
| 65 |
except Exception as e:
|
| 66 |
+
print(f"Error in main loop: {e}")
|
| 67 |
+
time.sleep(TRACK_CHECK_INTERVAL)
|
| 68 |
+
current_track_id += 1
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
+
main()
|