Skip to content

Instantly share code, notes, and snippets.

@progfolio
Created March 8, 2022 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save progfolio/44c00a0242f87e6db58e66eba032746d to your computer and use it in GitHub Desktop.
Save progfolio/44c00a0242f87e6db58e66eba032746d to your computer and use it in GitHub Desktop.
Most Published MELPA Authors
;;; smelpa.el --- Scrapes MELPA -*- lexical-binding: t; -*-
;; Copyright (C) 2022 Nicholas Vollmer
;; Author: Nicholas Vollmer
;; Keywords: convenience
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'url)
(require 'cl-lib)
(defvar url-http-end-of-headers)
(defvar smelpa-json nil "Melpa recipe JSON data.")
(defun smelpa-json ()
"Return an alist of MELPA recipe metadata."
(or smelpa-json
(setq smelpa-json
(with-current-buffer (url-retrieve-synchronously "https://melpa.org/archive.json")
(goto-char url-http-end-of-headers)
(json-read)))))
(defun smelpa-packages-by-author ()
"Return alist of form: ((author . (package-url...)))."
(let (authors)
(cl-loop for (_ . data) in (smelpa-json)
do (when-let ((props (alist-get 'props data))
(url (alist-get 'url props))
(parsed (url-generic-parse-url url))
(filename (url-filename parsed))
(tokens (split-string filename "/" 'omit-nulls))
(author (intern (car tokens))))
(if (alist-get author authors)
(push url (alist-get author authors))
(push (cons author (list url)) authors))))
authors))
(defun smelpa-most-published-authors (n)
"Return alist of form ((author . (url...))) for top N published MELPA authors."
(let ((authors (smelpa-packages-by-author)))
(cl-subseq
(cl-sort authors #'>
:key (lambda (cell) (length (cdr cell))))
0 (min n (length authors)))))
;; Top ten published authors: (mapcar #'car (smelpa-most-published-authors 10))
(provide 'smelpa)
;;; smelpa.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment