jerrrycans commited on
Commit
153f6e7
·
verified ·
1 Parent(s): 8c4a5c5

Update ccc.py

Browse files
Files changed (1) hide show
  1. ccc.py +12 -8
ccc.py CHANGED
@@ -9,8 +9,8 @@ WEBHOOK_URL = os.environ['web']
9
  BASE_URL = "https://tidal.com/browse/track/"
10
 
11
  # Configuration - Edit these values as needed
12
- START_TRACK_ID = 128449033 # Change this to your desired starting track ID
13
- TRACK_CHECK_INTERVAL = 0.5 # Speed of checking in seconds (lower = faster)
14
 
15
  def send_webhook_message(track_link, track_info):
16
  data = {
@@ -23,16 +23,17 @@ def send_webhook_message(track_link, track_info):
23
 
24
  def check_tidal_track(track_id):
25
  try:
26
- url = f"{BASE_URL}{track_id}"
27
  headers = {
28
- "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"
29
  }
30
  response = requests.get(url, headers=headers, timeout=5)
31
 
 
32
  if response.status_code == 200:
33
  soup = BeautifulSoup(response.content, 'html.parser')
34
 
35
- # Check if track exists by looking for the title
36
  title_element = soup.find('h1', class_="font-size-regular mt-0 mb-0 ellipsis-double overflow-hidden")
37
 
38
  if title_element:
@@ -42,7 +43,10 @@ def check_tidal_track(track_id):
42
 
43
  track_info = f"{title_element.text}\n{artist_name}"
44
  return True, track_info
45
-
 
 
 
46
  return False, None
47
  except Exception as e:
48
  print(f"Error checking track {track_id}: {e}")
@@ -58,7 +62,7 @@ def main():
58
  track_exists, track_info = check_tidal_track(current_track_id)
59
 
60
  if track_exists:
61
- track_link = f"{BASE_URL}{current_track_id}"
62
  print(f"Found valid track: {track_link} - {track_info}")
63
  send_webhook_message(track_link, track_info)
64
  else:
@@ -73,4 +77,4 @@ def main():
73
  current_track_id += 1
74
 
75
  if __name__ == "__main__":
76
- main()
 
9
  BASE_URL = "https://tidal.com/browse/track/"
10
 
11
  # Configuration - Edit these values as needed
12
+ START_TRACK_ID = 1000 # Change this to your desired starting track ID
13
+ TRACK_CHECK_INTERVAL = 0.1 # Speed of checking in seconds (lower = faster)
14
 
15
  def send_webhook_message(track_link, track_info):
16
  data = {
 
23
 
24
  def check_tidal_track(track_id):
25
  try:
26
+ url = f"{BASE_URL}{track_id}/u"
27
  headers = {
28
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"
29
  }
30
  response = requests.get(url, headers=headers, timeout=5)
31
 
32
+ # Check status code first - 200 means it exists, 404 means it doesn't
33
  if response.status_code == 200:
34
  soup = BeautifulSoup(response.content, 'html.parser')
35
 
36
+ # Try to find the track title
37
  title_element = soup.find('h1', class_="font-size-regular mt-0 mb-0 ellipsis-double overflow-hidden")
38
 
39
  if title_element:
 
43
 
44
  track_info = f"{title_element.text}\n{artist_name}"
45
  return True, track_info
46
+ else:
47
+ # If we got a 200 but couldn't find the title, still consider it valid
48
+ return True, "Unknown Track"
49
+
50
  return False, None
51
  except Exception as e:
52
  print(f"Error checking track {track_id}: {e}")
 
62
  track_exists, track_info = check_tidal_track(current_track_id)
63
 
64
  if track_exists:
65
+ track_link = f"{BASE_URL}{current_track_id}/u"
66
  print(f"Found valid track: {track_link} - {track_info}")
67
  send_webhook_message(track_link, track_info)
68
  else:
 
77
  current_track_id += 1
78
 
79
  if __name__ == "__main__":
80
+ main()