Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All gabc files under scores/gabc/ ? #11

Open
martindonat opened this issue Mar 23, 2017 · 5 comments
Open

All gabc files under scores/gabc/ ? #11

martindonat opened this issue Mar 23, 2017 · 5 comments

Comments

@martindonat
Copy link

For a bigger chant book-project I would need a lot of gabc scores from Gregobase, so I don't want to download them manually. I know, it shouldn't be such a problem: Download this repo, set up a local MySQL server, run the correct php-script, etc

After some considerable amount of time and effort I have a local MariaDB server, I imported the scores, but now I have encoding problems and am fed up... Sorry, I'm just not so familiar with SQL servers, php and this stuff. So I wanted to ask for this little favour, whether you could provide all gabc files in a dir like scores/gabc/.

I guess for you it would be much easier than for me.

Thanks in advance.

@igneus
Copy link
Contributor

igneus commented Aug 28, 2018

Do you still need the scores?

@martindonat
Copy link
Author

martindonat commented Aug 29, 2018

No, thanks. I did it the quick and dirty way: A python script which downloads file per file from the website. It looks like this:


def extract_filename(input_str, num):

	filename_pos = input_str.find("filename=")
	
	# "filename=" nicht gefunden
	if filename_pos == -1:
	
		print("Filename not found: {0}".format(num))
		return None
	
	# "filename=" gefunden	
	else:
	
		# vorne abschneiden
		filename = input_str[filename_pos + 9:]
	
		# evtl hinten abschneiden
		if filename.find(";") != -1:
	
			filename = filename[:filename.find(";")]
	
		return filename

for i in range(1148,9000):

	print("Download file ... {0}".format(i))

	# Request to URL
	gabc_download = urllib.request.urlopen("https://gregobase.selapa.net/download.php?id={0}&format=gabc".format(i))
	
	# Get Info Header
	info_str = gabc_download.info()['Content-Disposition']
	
	# Check if anything is found
	if info_str:
	
		#Extract filename
		filename = extract_filename(info_str, i)
	
		# Check if filename was found
		if filename:
	
			# Write the file
			with open("SCORES2/" + filename, "w") as f:
	
				f.write(gabc_download.read().decode("utf-8"))

So maybe it would be nice for other people to have the data in a more convenient way, but I have the data I needed.

@igneus
Copy link
Contributor

igneus commented Aug 29, 2018

OK. Should anyone in future need the data, I can provide them.
And if I ever finish my toy project of an alternative read-only frontend over the GregoBase database, mass export of the scores will be part of it.

@jjbauer15
Copy link

@igneus Is there any update on this? Conversely, would read-only credentials to the database itself be on the table? Thank you!

@igneus
Copy link
Contributor

igneus commented Nov 16, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants