mdium

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 4 Imported by: 0

README

mdium

mdium is a Go package for downloading Medium articles as markdown files.

EN TR

Tech Stack

Go PkgGoDev RSS Markdown YAML

Requirements

  • Go 1.23 or higher

Installation

As a Package
go get github.com/0xydev/mdium@v0.1.0
As a Command Line Tool
go install github.com/0xydev/mdium/cmd/mdium@v0.1.0

Features

  • Download articles from:
    • User profiles (e.g., @Medium)
    • Medium blogs (e.g., blog.medium.com)
    • Publications (e.g., medium.com/netflix-techblog)
  • Convert articles to markdown with YAML frontmatter
  • Limit the number of articles to download
  • Customizable output directory

Usage

Command Line
# Download from a user profile
go run cmd/mdium/main.go -user Medium -output user_articles -limit 5

# Download from Medium's blog
go run cmd/mdium/main.go -domain blog.medium.com -output blog_articles -limit 3

# Download from a publication
go run cmd/mdium/main.go -domain medium.com/netflix-techblog -output pub_articles
As a Package
package main

import (
    "log"
    "github.com/0xydev/mdium"
)

func main() {
    // Download from a user profile
    client, err := mdium.NewClient("Medium", "articles")
    if err != nil {
        log.Fatal(err)
    }
    
    err = client.DownloadArticles(5)
    if err != nil {
        log.Fatal(err)
    }

    // Download from a publication
    pubClient, err := mdium.NewClient("medium.com/netflix-techblog", "netflix_articles")
    if err != nil {
        log.Fatal(err)
    }
    
    err = pubClient.DownloadArticles(0) // Download all available articles
    if err != nil {
        log.Fatal(err)
    }
}

Output Format

Articles are saved as markdown files with YAML frontmatter:

---
title: "Article Title"
date: 2024-02-19T10:00:00Z
link: "https://medium.com/..."
author: "Author Name"
---

Article content in markdown...

Limitations

  • Medium's RSS feed is limited to the latest 10 articles
  • Some Medium articles might have formatting differences when converted to markdown

License

MIT License - see LICENSE file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Medium article downloader

func NewClient

func NewClient(source string, outputDir string) (*Client, error)

NewClient creates a new Medium client source can be either a username or a domain (blog.medium.com or medium.com/publication) outputDir is the directory where markdown files will be saved

func (*Client) DownloadArticles

func (c *Client) DownloadArticles(limit int) error

DownloadArticles downloads Medium articles limit: number of latest articles to download (0 means all articles) Returns an error if the download process fails

type SourceType

type SourceType int

SourceType represents the type of Medium source (user or domain)

const (
	// UserSource represents a Medium user profile
	UserSource SourceType = iota
	// DomainSource represents a Medium blog or publication
	DomainSource
)

Directories

Path Synopsis
cmd
mdium command
internal
fetcher
Package fetcher provides functionality to fetch articles from Medium
Package fetcher provides functionality to fetch articles from Medium

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL