Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
get_sourceforge_group_id.py
#!/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 <elliot@elliotjordan.com>
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']
#!/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 <elliot@elliotjordan.com>
# 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
You can’t perform that action at this time.