MuGeminorum commited on
Commit
d9324d8
1 Parent(s): 84b0e54

add cdn url

Browse files
Files changed (1) hide show
  1. music_genre.py +15 -2
music_genre.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import random
3
  import datasets
4
  from datasets.tasks import ImageClassification
@@ -35,7 +36,9 @@ _NAMES_3 = {
35
  22: "Acoustic_pop"
36
  }
37
 
38
- _HOMEPAGE = f"https://huggingface.co/datasets/ccmusic-database/{os.path.basename(__file__).split('.')[0]}"
 
 
39
 
40
  _CITATION = """\
41
  @dataset{zhaorui_liu_2021_5676893,
@@ -55,7 +58,17 @@ This database contains about 1700 musical pieces (.mp3 format)
55
  with lengths of 270-300s that are divided into 17 genres in total.
56
  """
57
 
58
- _URL = _HOMEPAGE + "/resolve/main/data/data.zip"
 
 
 
 
 
 
 
 
 
 
59
 
60
 
61
  class music_genre(datasets.GeneratorBasedBuilder):
 
1
  import os
2
+ import socket
3
  import random
4
  import datasets
5
  from datasets.tasks import ImageClassification
 
36
  22: "Acoustic_pop"
37
  }
38
 
39
+ _NAME = os.path.basename(__file__).split('.')[0]
40
+
41
+ _HOMEPAGE = f"https://huggingface.co/datasets/ccmusic-database/{_NAME}"
42
 
43
  _CITATION = """\
44
  @dataset{zhaorui_liu_2021_5676893,
 
58
  with lengths of 270-300s that are divided into 17 genres in total.
59
  """
60
 
61
+
62
+ def _cdn_url(ip='10.115.8.4', port=80):
63
+ try:
64
+ # create a socket connection
65
+ with socket.create_connection((ip, port), timeout=5):
66
+ return f'http://{ip}/{_NAME}/data/data.zip'
67
+ except (socket.timeout, socket.error):
68
+ return f"{_HOMEPAGE}/resolve/main/data/data.zip"
69
+
70
+
71
+ _URL = _cdn_url()
72
 
73
 
74
  class music_genre(datasets.GeneratorBasedBuilder):