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 \
|
||||
--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:
|
||||
./i2p.plugins.tor-manager -nounpack -notor -os win
|
||||
./i2p.plugins.tor-manager -nounpack -notor -os osx
|
||||
./i2p.plugins.tor-manager -nounpack -notor -os linux
|
||||
./i2p.plugins.tor-manager -nounpack -notor -os win -arch 32
|
||||
./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 win -lang "$(LANG)" #-torrent $(TORRENT)
|
||||
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os osx -lang "$(LANG)" #-torrent $(TORRENT)
|
||||
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os linux -lang "$(LANG)" #-torrent $(TORRENT)
|
||||
TOR_MANAGER_CLEARNET_MIRROR=true TOR_MANAGER_REQUIRE_PASSWORD=false ./i2p.plugins.tor-manager -nounpack -notor -os win -arch 32 -lang "$(LANG)" #-torrent $(TORRENT)
|
||||
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.
|
||||
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 (
|
||||
// DefaultIETFLang is the default language for the TBDownloader.
|
||||
DefaultIETFLang, _ = jibber_jabber.DetectIETF()
|
||||
|
@ -38,7 +38,8 @@ func (t *TBDownloader) GenerateMissingTorrents() error {
|
||||
fp := filepath.Join(t.DownloadPath, f+".torrent")
|
||||
af := filepath.Join(t.DownloadPath, f)
|
||||
if !strings.HasSuffix(af, ".torrent") {
|
||||
os.Remove(fp)
|
||||
//os.Remove(fp)
|
||||
if !FileExists(fp) {
|
||||
log.Println("Generating torrent for", fp)
|
||||
meta, err := t.GenerateTorrent(af, nil)
|
||||
if err != nil {
|
||||
@ -53,22 +54,29 @@ func (t *TBDownloader) GenerateMissingTorrents() error {
|
||||
meta.Write(file)
|
||||
file.Close()
|
||||
}
|
||||
}
|
||||
snark, err := FindSnarkDirectory()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sf := filepath.Join(snark, f)
|
||||
sfp := filepath.Join(snark, f+".torrent")
|
||||
if !FileExists(sf) {
|
||||
log.Println("Copying", af, "to", sf)
|
||||
cp.Copy(af, sf)
|
||||
}
|
||||
if !FileExists(sfp) {
|
||||
log.Println("Copying", fp, "to", sfp)
|
||||
cp.Copy(fp, sfp)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
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 {
|
||||
return nil, fmt.Errorf("GenerateTorrent: %s", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user