Last active
March 18, 2019 17:44
-
-
Save homebysix/9640c6a6eecff82d3b16 to your computer and use it in GitHub Desktop.
get_sourceforge_group_id.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
Name: get_sourceforge_group_id.py | |
Description: Given the name of a SourceForge project, returns its group | |
ID. Useful for creating AutoPkg recipes that leverage the | |
SourceForgeURLProvider processor. | |
Author: Elliot Jordan <[email protected]> | |
Created: 2015-07-11 | |
Last Modified: 2015-07-11 | |
Version: 1.0 | |
''' | |
import urllib2 | |
import json | |
project_name = raw_input("Please enter the project name from the SourceForge URL: ") | |
project_api_url = "https://sourceforge.net/rest/p/" + project_name | |
raw_json = urllib2.urlopen(project_api_url).read() | |
parsed_json = json.loads(raw_json) | |
for this_dict in parsed_json['tools']: | |
try: | |
this_dict['sourceforge_group_id'] | |
except KeyError: | |
pass | |
else: | |
print this_dict['sourceforge_group_id'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### | |
# | |
# Name: get_sourceforge_group_id.sh | |
# Description: Given the name of a SourceForge project, returns its group | |
# ID. Useful for creating AutoPkg recipes that leverage the | |
# SourceForgeURLProvider processor. | |
# Author: Elliot Jordan <[email protected]> | |
# Created: 2015-07-11 | |
# Last Modified: 2015-07-11 | |
# Version: 1.0 | |
# | |
### | |
printf "Please enter the project name from the SourceForge URL: " | |
read project_name | |
curl -s "https://sourceforge.net/rest/p/$project_name" \ | |
| sed -e 's/[]{}[]//g' \ | |
| awk -v RS=',' -F "\"sourceforge_group_id\": " '/sourceforge_group_id/{print $2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment