<commit_before>/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"

	"golang.org/x/oauth2"
	"google.golang.org/api/googleapi"
	"google.golang.org/api/youtube/v3"
)

type chanChan chan chan struct{}

var (
	filename          = flag.String("filename", "", "video filename. Can be a URL. Read from stdin with '-'")
	thumbnail         = flag.String("thumbnail", "", "thumbnail filename. Can be a URL")
	caption           = flag.String("caption", "", "caption filename. Can be a URL")
	title             = flag.String("title", "video title", "video title")
	description       = flag.String("description", "uploaded by youtubeuploader", "video description")
	language          = flag.String("language", "en", "video language")
	categoryId        = flag.String("categoryId", "", "video category Id")
	tags              = flag.String("tags", "", "comma separated list of video tags")
	privacy           = flag.String("privacy", "private", "video privacy status")
	quiet             = flag.Bool("quiet", false, "suppress progress indicator")
	rate              = flag.Int("ratelimit", 0, "rate limit upload in Kbps. No limit by default")
	metaJSON          = flag.String("metaJSON", "", "JSON file containing title,description,tags etc (optional)")
	metaJSONout       = flag.String("metaJSONout", "", "filename to write uploaded video metadata into (optional)")
	limitBetween      = flag.String("limitBetween", "", "only rate limit between these times e.g. 10:00-14:00 (local time zone)")
	headlessAuth      = flag.Bool("headlessAuth", false, "set this if no browser available for the oauth authorisation step")
	oAuthPort         = flag.Int("oAuthPort", 8080, "TCP port to listen on when requesting an oAuth token")
	showAppVersion    = flag.Bool("version", false, "show version")
	chunksize         = flag.Int("chunksize", googleapi.DefaultUploadChunkSize, "size (in bytes) of each upload chunk. A zero value will cause all data to be uploaded in a single request")
	notifySubscribers = flag.Bool("notify", true, "notify channel subscribers of new video")

	// this is set by compile-time to match git tag
	appVersion string = "unknown"
)

func main() {
	flag.Parse()

	if *showAppVersion {
		fmt.Printf("Youtubeuploader version: %s\n", appVersion)
		os.Exit(0)
	}

	if *filename == "" {
		fmt.Printf("\nYou must provide a filename of a video file to upload\n")
		fmt.Printf("\nUsage:\n")
		flag.PrintDefaults()
		os.Exit(1)
	}

	var reader io.ReadCloser
	var filesize int64
	var err error

	var limitRange limitRange
	if *limitBetween != "" {
		limitRange, err = parseLimitBetween(*limitBetween)
		if err != nil {
			fmt.Printf("Invalid value for -limitBetween: %v", err)
			os.Exit(1)
		}<commit_msg>Set video title to video file name by default<commit_after>/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path/filepath"
	"strings"
	
	"golang.org/x/oauth2"
	"google.golang.org/api/googleapi"
	"google.golang.org/api/youtube/v3"
)

type chanChan chan chan struct{}

var (
	filename          = flag.String("filename", "", "video filename. Can be a URL. Read from stdin with '-'")
	thumbnail         = flag.String("thumbnail", "", "thumbnail filename. Can be a URL")
	caption           = flag.String("caption", "", "caption filename. Can be a URL")
	title             = flag.String("title", "", "video title")
	description       = flag.String("description", "uploaded by youtubeuploader", "video description")
	language          = flag.String("language", "en", "video language")
	categoryId        = flag.String("categoryId", "", "video category Id")
	tags              = flag.String("tags", "", "comma separated list of video tags")
	privacy           = flag.String("privacy", "private", "video privacy status")
	quiet             = flag.Bool("quiet", false, "suppress progress indicator")
	rate              = flag.Int("ratelimit", 0, "rate limit upload in Kbps. No limit by default")
	metaJSON          = flag.String("metaJSON", "", "JSON file containing title,description,tags etc (optional)")
	metaJSONout       = flag.String("metaJSONout", "", "filename to write uploaded video metadata into (optional)")
	limitBetween      = flag.String("limitBetween", "", "only rate limit between these times e.g. 10:00-14:00 (local time zone)")
	headlessAuth      = flag.Bool("headlessAuth", false, "set this if no browser available for the oauth authorisation step")
	oAuthPort         = flag.Int("oAuthPort", 8080, "TCP port to listen on when requesting an oAuth token")
	showAppVersion    = flag.Bool("version", false, "show version")
	chunksize         = flag.Int("chunksize", googleapi.DefaultUploadChunkSize, "size (in bytes) of each upload chunk. A zero value will cause all data to be uploaded in a single request")
	notifySubscribers = flag.Bool("notify", true, "notify channel subscribers of new video")

	// this is set by compile-time to match git tag
	appVersion string = "unknown"
)

func main() {
	flag.Parse()

	if *showAppVersion {
		fmt.Printf("Youtubeuploader version: %s\n", appVersion)
		os.Exit(0)
	}

	if *filename == "" {
		fmt.Printf("\nYou must provide a filename of a video file to upload\n")
		fmt.Printf("\nUsage:\n")
		flag.PrintDefaults()
		os.Exit(1)
	}
	
	if *title == "" {
		*title = strings.Replace(filepath.Base(*filename),filepath.Ext(*filename),"",-1)
	}

	var reader io.ReadCloser
	var filesize int64
	var err error

	var limitRange limitRange
	if *limitBetween != "" {
		limitRange, err = parseLimitBetween(*limitBetween)
		if err != nil {
			fmt.Printf("Invalid value for -limitBetween: %v", err)
			os.Exit(1)
		}
{'fraction_non_alphanumeric': 0.12308379223098675, 'fraction_numerical': 0.00729275189760381, 'mean_word_length': 3.6634281748785567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2085775', 'n_tokens_mistral': 2106, 'n_tokens_neox': 1986, 'n_words': 700}