File size: 5,517 Bytes
7b88c07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
from xenopy import Query


SPECIES = [
    "American Robin",
    "Northern Cardinal",
    "Mourning Dove",
    "American Crow",
    "Baltimore Oriole",
    "Blue Jay",
    "Eastern Bluebird",
    "House Finch",
    "American Goldfinch",
    "House Sparrow",
    "Song Sparrow",
    "Tufted Titmouse",
    "White-breasted Nuthatch",
    "European Starling",
    "American Redstart",
    "Red-winged Blackbird",
    "Brown-headed Cowbird",
    "Common Grackle",
    "Boat-tailed Grackle",
    "Common Yellowthroat",
    "Northern Mockingbird",
    "Carolina Wren",
    "Eastern Meadowlark",
    "Chipping Sparrow",
    "Tree Swallow",
    "Barn Swallow",
    "Cliff Swallow",
    "Pine Siskin",
    "Indigo Bunting",
    "Eastern Towhee",
    "Carolina Chickadee",
    "Great Crested Flycatcher",
    "Eastern Wood-Pewee",
    "Ovenbird",
    "Northern Flicker",
    "Red-eyed Vireo",
    "American Woodcock",
    "Eastern Phoebe",
    "Downy Woodpecker",
    "Scarlet Tanager",
    "Yellow Warbler",
    "White-eyed Vireo",
    "Common Loon",
    "White-throated Sparrow",
    "Yellow-throated Vireo",
    "Great Blue Heron",
    "Belted Kingfisher",
    "Pied-billed Grebe",
    "Wild Turkey",
    "Wood Thrush",
    "Rose-breasted Grosbeak",
    "Field Sparrow",
    "Hooded Warbler",
    "Northern Parula",
    "Chestnut-sided Warbler",
    "Blue-winged Warbler",
    "Red-bellied Woodpecker",
    "Yellow-billed Cuckoo",
    "Gray Catbird",
    "Northern Saw-whet Owl",
    "Osprey",
    "Common Nighthawk",
    "Broad-winged Hawk",
    "Black-throated Green Warbler",
    "Great Horned Owl",
    "Common Raven",
    "Barred Owl",
    "Canada Warbler",
    "Magnolia Warbler",
    "Black-and-white Warbler",
    "Eastern Kingbird",
    "Swainson's Thrush",
    "Worm-eating Warbler",
    "Prairie Warbler",
    "Baltimore Oriole",
    "Black-throated Blue Warbler",
    "Louisiana Waterthrush",
    "Blackburnian Warbler",
    "Black-capped Chickadee",
    "Cerulean Warbler",
    "Red-shouldered Hawk",
    "Cooper's Hawk",
    "Yellow-throated Warbler",
    "Blue-headed Vireo",
    "Blackpoll Warbler",
    "Ruffed Grouse",
    "Kentucky Warbler",
    "Hermit Thrush",
    "Cedar Waxwing",
    "Eastern Screech-Owl",
    "Northern Goshawk",
    "Green Heron",
    "Red-tailed Hawk",
    "Black Vulture",
    "Hairy Woodpecker",
    "Golden-crowned Kinglet",
    "Ruby-crowned Kinglet",
    "Bicknell's Thrush",
    "Blue-gray Gnatcatcher",
    "Veery",
    "Pileated Woodpecker",
    "Purple Finch",
    "White-crowned Sparrow",
    "Snow Bunting",
    "Pine Grosbeak",
    "American Tree Sparrow",
    "Dark-eyed Junco",
    "Snowy Owl",
    "White-winged Crossbill",
    "Red Crossbill",
    "Common Redpoll",
    "Northern Shrike",
    "Northern Harrier",
    "Rough-legged Hawk",
    "Long-eared Owl",
    "Evening Grosbeak",
    "Northern Pintail",
    "American Black Duck",
    "Mallard",
    "Canvasback",
    "Redhead",
    "Ring-necked Duck",
    "Greater Scaup",
    "Lesser Scaup",
    "Bufflehead",
    "Common Goldeneye",
    "Hooded Merganser",
    "Common Merganser",
    "Red-breasted Merganser",
    "Ruddy Duck",
    "Wood Duck",
    "Gadwall",
    "American Wigeon",
    "Northern Shoveler",
    "Green-winged Teal",
    "Blue-winged Teal",
    "Cinnamon Teal",
    "Ringed Teal",
    "Cape Teal",
    "Northern Fulmar",
    "Yellow-billed Loon",
    "Red-throated Loon",
    "Arctic Loon",
    "Pacific Loon",
    "Horned Grebe",
    "Red-necked Grebe",
    "Eared Grebe",
    "Western Grebe",
    "Clark's Grebe",
    "Double-crested Cormorant",
    "Pelagic Cormorant",
    "Great Cormorant",
    "American White Pelican",
    "Brown Pelican",
    "Brandt's Cormorant",
    "Least Bittern",
    "Great Egret",
    "Snowy Egret",
    "Little Blue Heron",
    "Tricolored Heron",
    "Reddish Egret",
    "Black-crowned Night-Heron",
    "Yellow-crowned Night-Heron",
    "White Ibis",
    "Glossy Ibis",
    "Roseate Spoonbill",
    "Wood Stork",
    "Black-bellied Whistling-Duck",
    "Fulvous Whistling-Duck",
    "Greater White-fronted Goose",
    "Snow Goose",
    "Ross's Goose",
    "Canada Goose",
    "Brant",
    "Mute Swan",
    "Tundra Swan",
    "Whooper Swan",
    "Sandhill Crane",
    "Black-necked Stilt",
    "American Avocet",
    "Northern Jacana",
    "Greater Yellowlegs",
    "Lesser Yellowlegs",
    "Willet",
    "Spotted Sandpiper",
    "Upland Sandpiper",
    "Whimbrel",
    "Long-billed Curlew",
    "Marbled Godwit",
    "Ruddy Turnstone",
    "Red Knot",
    "Sanderling",
    "Semipalmated Sandpiper",
    "Western Sandpiper",
    "Least Sandpiper",
    "White-rumped Sandpiper",
    "Baird's Sandpiper",
    "Pectoral Sandpiper",
    "Dunlin",
    "Buff-breasted Sandpiper",
    "Short-billed Dowitcher",
    "Long-billed Dowitcher",
    "Common Snipe",
    "American Woodcock",
    "Wilson's Phalarope",
    "Red-necked Phalarope",
    "Red Phalarope"
]

from pathlib import Path

def remove_spaces(s):
    return s.replace(" ", "")

for species in SPECIES: 
    if Path("/media/CHONK/hugo/xeno-canto-full/" + remove_spaces(species)).exists():
        continue
    try:
        q = Query(
            name=species, q="A", length="10-30", 
            )

        # retrieve metadata
        metafiles = q.retrieve_meta(verbose=True)
        # retrieve recordings
        q.retrieve_recordings(multiprocess=True, nproc=10, attempts=10, outdir="/media/CHONK/hugo/xeno-canto-full/")

    except:
        print("Failed to download " + species)
        continue