Add mirror and torrent generation tools
This commit is contained in:
52
Makefile
52
Makefile
@ -348,9 +348,51 @@ docker: xhost
|
|||||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||||
--rm eyedeekay/i2p.plugins.tor-manager
|
--rm eyedeekay/i2p.plugins.tor-manager
|
||||||
|
|
||||||
|
LANG?=en-US
|
||||||
|
TORRENT?=false
|
||||||
|
|
||||||
|
all-torrents:
|
||||||
|
LANG=ro make torrents
|
||||||
|
LANG=ru make torrents
|
||||||
|
LANG=tr make torrents
|
||||||
|
LANG=en-US make torrents
|
||||||
|
LANG=ga-IE make torrents
|
||||||
|
LANG=pt-BR make torrents
|
||||||
|
LANG=es-ES make torrents
|
||||||
|
LANG=fa make torrents
|
||||||
|
LANG=it make torrents
|
||||||
|
LANG=ja make torrents
|
||||||
|
LANG=ka make torrents
|
||||||
|
LANG=ar make torrents
|
||||||
|
LANG=ca make torrents
|
||||||
|
LANG=da make torrents
|
||||||
|
LANG=my make torrents
|
||||||
|
LANG=th make torrents
|
||||||
|
LANG=de make torrents
|
||||||
|
LANG=hu make torrents
|
||||||
|
LANG=lt make torrents
|
||||||
|
LANG=he make torrents
|
||||||
|
LANG=ms make torrents
|
||||||
|
LANG=pl make torrents
|
||||||
|
LANG=zh-TW make torrents
|
||||||
|
LANG=id make torrents
|
||||||
|
LANG=ko make torrents
|
||||||
|
LANG=nl make torrents
|
||||||
|
LANG=zh-CN make torrents
|
||||||
|
LANG=el make torrents
|
||||||
|
LANG=fr make torrents
|
||||||
|
LANG=sv-SE make torrents
|
||||||
|
LANG=cs make torrents
|
||||||
|
LANG=es-AR make torrents
|
||||||
|
LANG=nb-NO make torrents
|
||||||
|
LANG=is make torrents
|
||||||
|
LANG=mk make torrents
|
||||||
|
LANG=vi make torrents
|
||||||
|
TORRENT=true LANG=vi make torrents
|
||||||
|
|
||||||
torrents:
|
torrents:
|
||||||
./i2p.plugins.tor-manager -nounpack -notor -os win
|
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os win -lang "$(LANG)" #-torrent $(TORRENT)
|
||||||
./i2p.plugins.tor-manager -nounpack -notor -os osx
|
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os osx -lang "$(LANG)" #-torrent $(TORRENT)
|
||||||
./i2p.plugins.tor-manager -nounpack -notor -os linux
|
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os linux -lang "$(LANG)" #-torrent $(TORRENT)
|
||||||
./i2p.plugins.tor-manager -nounpack -notor -os win -arch 32
|
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os win -arch 32 -lang "$(LANG)" #-torrent $(TORRENT)
|
||||||
./i2p.plugins.tor-manager -nounpack -notor -os linux -arch 32
|
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os linux -arch 32 -lang "$(LANG)" #-torrent $(TORRENT)
|
22
get/get.go
22
get/get.go
@ -67,6 +67,28 @@ func DOWNLOAD_PATH() string {
|
|||||||
// TOR_UPDATES_URL is the URL of the Tor Browser update list.
|
// TOR_UPDATES_URL is the URL of the Tor Browser update list.
|
||||||
const TOR_UPDATES_URL string = "https://aus1.torproject.org/torbrowser/update_3/release/downloads.json"
|
const TOR_UPDATES_URL string = "https://aus1.torproject.org/torbrowser/update_3/release/downloads.json"
|
||||||
|
|
||||||
|
func Languages() []string {
|
||||||
|
jsonText, err := http.Get(TOR_UPDATES_URL)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
defer jsonText.Body.Close()
|
||||||
|
jsonBytes, err := ioutil.ReadAll(jsonText.Body)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
var updates map[string]interface{}
|
||||||
|
if err := json.Unmarshal(jsonBytes, &updates); err != nil {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
var languages []string
|
||||||
|
//updates[]
|
||||||
|
for i := range updates["downloads"].(map[string]interface{})["win64"].(map[string]interface{}) {
|
||||||
|
languages = append(languages, i)
|
||||||
|
}
|
||||||
|
return languages
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// DefaultIETFLang is the default language for the TBDownloader.
|
// DefaultIETFLang is the default language for the TBDownloader.
|
||||||
DefaultIETFLang, _ = jibber_jabber.DetectIETF()
|
DefaultIETFLang, _ = jibber_jabber.DetectIETF()
|
||||||
|
@ -38,20 +38,22 @@ func (t *TBDownloader) GenerateMissingTorrents() error {
|
|||||||
fp := filepath.Join(t.DownloadPath, f+".torrent")
|
fp := filepath.Join(t.DownloadPath, f+".torrent")
|
||||||
af := filepath.Join(t.DownloadPath, f)
|
af := filepath.Join(t.DownloadPath, f)
|
||||||
if !strings.HasSuffix(af, ".torrent") {
|
if !strings.HasSuffix(af, ".torrent") {
|
||||||
os.Remove(fp)
|
//os.Remove(fp)
|
||||||
log.Println("Generating torrent for", fp)
|
if !FileExists(fp) {
|
||||||
meta, err := t.GenerateTorrent(af, nil)
|
log.Println("Generating torrent for", fp)
|
||||||
if err != nil {
|
meta, err := t.GenerateTorrent(af, nil)
|
||||||
//return err
|
if err != nil {
|
||||||
log.Println("GenerateMissingTorrents:", err)
|
//return err
|
||||||
continue
|
log.Println("GenerateMissingTorrents:", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
file, err := os.Create(fp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
meta.Write(file)
|
||||||
|
file.Close()
|
||||||
}
|
}
|
||||||
file, err := os.Create(fp)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
meta.Write(file)
|
|
||||||
file.Close()
|
|
||||||
}
|
}
|
||||||
snark, err := FindSnarkDirectory()
|
snark, err := FindSnarkDirectory()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -59,16 +61,22 @@ func (t *TBDownloader) GenerateMissingTorrents() error {
|
|||||||
}
|
}
|
||||||
sf := filepath.Join(snark, f)
|
sf := filepath.Join(snark, f)
|
||||||
sfp := filepath.Join(snark, f+".torrent")
|
sfp := filepath.Join(snark, f+".torrent")
|
||||||
log.Println("Copying", af, "to", sf)
|
if !FileExists(sf) {
|
||||||
cp.Copy(af, sf)
|
log.Println("Copying", af, "to", sf)
|
||||||
log.Println("Copying", fp, "to", sfp)
|
cp.Copy(af, sf)
|
||||||
cp.Copy(fp, sfp)
|
}
|
||||||
|
if !FileExists(sfp) {
|
||||||
|
log.Println("Copying", fp, "to", sfp)
|
||||||
|
cp.Copy(fp, sfp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TBDownloader) GenerateTorrent(file string, announces []string) (*metainfo.MetaInfo, error) {
|
func (t *TBDownloader) GenerateTorrent(file string, announces []string) (*metainfo.MetaInfo, error) {
|
||||||
info, err := metainfo.NewInfoFromFilePath(file, 5120)
|
|
||||||
|
//info, err := metainfo.NewInfoFromFilePath(file, 5120)
|
||||||
|
info, err := metainfo.NewInfoFromFilePath(file, 10240)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("GenerateTorrent: %s", err)
|
return nil, fmt.Errorf("GenerateTorrent: %s", err)
|
||||||
}
|
}
|
||||||
|
4
main.go
4
main.go
@ -184,6 +184,10 @@ func main() {
|
|||||||
fmt.Printf("Options:\n")
|
fmt.Printf("Options:\n")
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
usage()
|
usage()
|
||||||
|
log.Printf("Available Languages:\n")
|
||||||
|
for _, l := range tbget.Languages() {
|
||||||
|
fmt.Printf(" - %s\n", l)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *ptop {
|
if *ptop {
|
||||||
|
Reference in New Issue
Block a user