tv_rename/functions.hpp

93 lines
2.5 KiB
C++
Raw Normal View History

2019-02-04 16:39:48 +00:00
#ifndef TV_FUNCTIONS_H
#define TV_FUNCTIONS_H
2018-09-22 22:50:42 +00:00
#include <map>
2019-02-04 16:39:48 +00:00
#include <set>
#include <string>
2019-07-12 21:10:40 +00:00
#include <unordered_map>
#include <unordered_set>
2019-01-23 19:46:03 +00:00
#include <vector>
2019-02-04 16:39:48 +00:00
#include "network.hpp"
#ifdef _WIN32
using string = std::wstring;
using char_t = wchar_t;
std::wstring utf8_to_wstring( const std::string &utf8 );
2020-04-01 11:42:00 +00:00
std::wstring LMsg( int id, ... );
2020-03-12 19:52:23 +00:00
2020-04-01 11:42:00 +00:00
#define _( x, ... ) LMsg( x, ##__VA_ARGS__ ).c_str()
2019-02-04 16:39:48 +00:00
#else
2020-03-12 19:52:23 +00:00
#include <libintl.h>
2019-02-04 16:39:48 +00:00
using string = std::string;
using char_t = char;
2020-03-12 19:52:23 +00:00
std::string getlocalized( const char *id, ... );
#define TEXT( x ) x
#define _( x, ... ) getlocalized( x, ##__VA_ARGS__ )
2020-01-15 23:00:58 +00:00
2019-02-04 16:39:48 +00:00
#endif
2019-07-12 21:10:40 +00:00
#ifndef GUI
// CLI functions
2018-09-22 22:50:42 +00:00
void printHelp();
2020-03-12 19:52:23 +00:00
void printPatternHelp();
2018-09-22 22:50:42 +00:00
2019-02-04 16:39:48 +00:00
bool searchSeason( const char_t *const path, size_t &season_pos );
bool searchSeason( const char_t *const path, size_t &season_pos,
size_t &ep_pos );
2019-02-04 16:39:48 +00:00
void parseSeasonNumbers( std::set< int > &seasons_num, const char_t *argument );
2019-01-19 12:40:10 +00:00
#endif // GUI
2019-01-23 19:46:03 +00:00
2020-01-16 10:12:22 +00:00
string encodeUrl( const string &url );
2019-06-04 19:54:00 +00:00
string userHome();
2020-01-15 22:59:39 +00:00
void prepareDB( const string &_pattern = TEXT( "" ) );
2019-06-04 19:54:00 +00:00
#ifndef GUI
2020-01-18 21:18:58 +00:00
void addToDB( string &show, const string &path, const string &language,
bool unix_names, bool dvd );
2019-07-12 21:10:40 +00:00
#else
void addToDB( const string &show, const string &path, const string &language,
const string &id, const string &pattern, bool unix_names,
bool dvd, void *progress_ptr );
2019-07-12 21:10:40 +00:00
#endif
2019-06-04 19:54:00 +00:00
void removeFromDB( const string &path );
void changeDBPattern( const string &pattern );
#ifndef GUI
void refreshDB( bool unix_names );
void updateDB( bool unix_names );
void cleanDB();
#else
void refreshDB( bool unix_names, void *progress_ptr );
void updateDB( bool unix_names, void *progress_ptr );
void cleanDB( void *progress_ptr );
#endif
2020-01-18 21:18:58 +00:00
#ifdef GUI
std::vector< std::unordered_map< string, string > > dbGetShows();
2019-07-12 21:10:40 +00:00
void changeDB( size_t index, const string &path, const string &language,
const string &id, bool dvd );
void refreshSelectDB( std::unordered_set< size_t > indexes, bool unix_names,
void *progress_ptr );
void renameFiles( const std::vector< std::tuple< int, string, string, string > >
&renamed_files );
#endif
2019-06-04 19:54:00 +00:00
2020-01-15 18:55:24 +00:00
void iterateFS( std::map< int, std::map< int, string > > &seasons,
2019-02-04 16:39:48 +00:00
const string &path );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
string compilePattern( const string &pattern, int season, int episode,
const string &filename, const string &episodeName,
const string &showName );
string getDBPattern();
2019-01-21 19:30:14 +00:00
2018-09-22 22:50:42 +00:00
#endif